ankitsultana / subtitle-downloader

A OS X Service to download subtitles in three clicks
http://ankitsultana.com/subtitle-downloader
19 stars 1 forks source link

Unable to run the script #1

Closed nu-vi closed 9 years ago

nu-vi commented 9 years ago

After the installation I tried to run the script but a message like this appears: "The action “Execute shell script” found an error". Also, when I right click a movie the action Services doesn't appear, only the Get Subtitles option directly.

ankitsultana commented 9 years ago

The action "Services" only appears when there are enough "Services". So it's quite normal for Services to not appear. I need you to answer these questions for me:

  1. Where exactly did you follow the instructions, README or here
  2. Were you able to run install.sh successfully or not.
  3. The error "The action: "Execute shell script" found an error" occured when exactly? How did you try to "run the script"?

Edit: Do check if you moved the folder Sub-Downloader to your home directory or not.

It might be possible that the subtitles for a given file might not exist in thesubdb's Database. Download sample files from their website here, and right click and then "Get Subtitles". If they download, that implies the script is working fine.

If the issue still persists copy the logs.txt file in ~/Sub-Downloader and paste its contents here.

nu-vi commented 9 years ago

First I installed using GIT, but since it was not working I followed the instructions on your website (changing the name in the mv command to the name of the downloaded file of course). I ran the install.sh successfully and requests was installed properly. The error occurs every time I right click a movie and click in "Get Subtitles". It refers to the "Get Subtitles.workflow" present in users/myusername/Library/Services/Get Subtitles.workflow

The Sub-Downloader is in my home directory (and so is the requests folder) and I have tried with numerous movies including sample files but it keeps resulting in the same error, I'm running OS X 10.10.5 by the way.

Strangely the Logs.txt file only says the following: "Requests is installed Moving Get Subtitles.workflow"

ankitsultana commented 9 years ago

I have updated main_script.py to write logs to script.log, along with some minor updates elsewhere in the Repo. What I strongly recommend you to do is delete and then try a fresh install.

To Delete the Service and all files:

rm -rf ~/Sub-Downloader
rm -rf ~/Library/Services/Get\ Subtitles.workflow/

Once this is done, follow the instructions as mentioned in README. Also it is important that you clone the repo again and follow the instructions.

If you still get an error while trying to download subtitles, then go to ~/Sub-Downloader and copy the contents of script.log and paste them here. Note that script.log is created after the first time you try to download subtitles by clicking on Get Subtitles. If no such file exists even after trying to download using Get Subtitles, then let me know.

Edit: I have added logs to be written to script.log that rests inside the Sub-Downloader directory. You should be able to figure out what's wrong with your installation now.

nu-vi commented 9 years ago

I re-installed it and checked the logs, it seems requests isn't installed properly. Here is the log: "main - INFO - Trying Imports main - INFO - Imported sys, os and re main - INFO - Imported meta_extract, hash_video main - ERROR - Cannot Import Requests main - INFO - Extracting Meta Data from File Name main - INFO - File Name: dexter main - INFO - Directory: /Users/nuvi/Desktop main - INFO - Extension: .mp4 main - INFO - Extracted Meta Data"

nu-vi commented 9 years ago

Ok so, I uninstalled requests (sudo pip uninstall requests) and Sub-Downloader. Then I cloned Sub-Downloader and installed it again, responding yes when asked whether requests to be installed I answered yes (Y). The problem wasn't solved and the logs are the same as before

ankitsultana commented 9 years ago

Clearly the script can't import requests. Open up terminal and start a python session (2.x not 3.x), generally done by typing python. Try to import requests now, if it cannot, then the reason is that requests didn't install. Try this,

  1. Do a pip freeze in terminal to check if requests in installed. If it is installed, uninstall it using pip again, and check pip freeze again to see if it is removed or not.
  2. Clone requests to your home directory, then install using python setup.py install. To summarise

    cd ~
    git clone https://github.com/kennethreitz/requests.git
    cd ~/requests
    python setup.py install

Now start a python 2.x session and try and import requests and then try the script. To put in another way, script will only work if you are able to import requests in python 2.x.

The script itself is fine. Problem in your case is installation of requests. For that I am considering to remove install.sh or update it. Do tell me if it works.

nu-vi commented 9 years ago

Sorry for the late reply, I've been busy. I'm trying this from a clean os x 10.10.5 install. I have python 2.7 installed and I have installed requests from source as requested. I'm able to import requests fine on a python session but I still get the same error and same script.log results. For some reason the script isn't importing requests. Do you know what can be causing this?

Thank you for your time

ankitsultana commented 9 years ago

A few clarifications:

  1. Make sure that you get a python 2.x session when you type python in terminal.
  2. Make sure you are able to then import requests.

If anything is not as mentioned above, let me know

To find the issue that's causing this:

  1. Update main_script, I have updated it at the time of writing this answer. Note that you can do git pull in the Sub-Downloader directory to do that.
  2. Delete the script.log file if it exists in the Sub-Downloader directory.
  3. Try Get Subtitles for some movie file again.
  4. If it works, let me know, else
  5. Check script.log, which should be created again and paste its contents here.

What I have done:

  1. I am now writing the python version invoked by Get Subtitles to script.log.
  2. Most importantly I am now writing value of sys.path in case requests cannot be imported. For requests to be "importable", it should be there in sys.path.

Probable Cause:

  1. Most probably requests is not there in sys.path.
  2. Get Subtitles invokes a python version that can't import requests.
  3. Something messed up while installing requests. I found a similar issue on stack overflow. Don't try what the guy who answered it has said yet. First paste the script.log's contents here. Your issue might not be the same as the one mentioned in the question.

Knowing both the python version that gets invoked and the value of sys.path, We can probably solve your issue.

nu-vi commented 9 years ago

Ok so, when I evoke a python session and import requests this is what happens:

MBP-de-Nuno:~ nuvi$ python Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. import requests quit()

So I can import requests fine on terminal.

As for the new script.log here is what I got: main - INFO - 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] main - INFO - Trying Imports main - INFO - Imported sys, os and re main - INFO - Imported meta_extract, hash_video main - ERROR - Cannot Import Requests main - ERROR - No module named requests Traceback (most recent call last): File "main_script.py", line 42, in import requests ImportError: No module named requests main - ERROR - ['/Users/nuvi/Sub-Downloader', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages'] main - INFO - Extracting Meta Data from File Name main - INFO - File Name: 216 - Lesser Evil main - INFO - Directory: /Users/nuvi main - INFO - Extension: .avi main - INFO - Extracted Meta Data

ankitsultana commented 9 years ago

EDIT: I have removed the need for requests.

You just need to do the following:

  1. Remove current Sub-Downloader directory from your home-directory and from ~/Library/Services/ and clone it again from the repo. In terminal, to summarize:

    cd ~
    rm -rf ~/Sub-Downloader
    rm -rf ~/Library/Services/Get\ Subtitles.workflow
    git clone https://github.com/bk2dcradle/Sub-Downloader
    mv ~/Sub-Downloader/Get\ Subtitles.workflow ~/Library/Services/
  2. Test the script on some sample file downloaded from thesubdb's website. Let me know as well.