clinton-hall / nzbToMedia

Provides NZB and Torrent postprocessing To CouchPotatoServer, SickBeard/SickRage, HeadPhones, Mylar and Gamez
GNU General Public License v3.0
673 stars 176 forks source link

Could not parse database results to determine imdbid or movie id #184

Closed jkurelek closed 11 years ago

jkurelek commented 11 years ago

First off want to thank everyone for creating an awesome script.

Using TorrentToMedia to post-process movies from CPS downloaded using uTorrent and having a problem with the script determining the imdb ID. It hasn't worked since day one and a movie is only successfully post-processed if it came with an nfo.

TorrentToMedia

20:15:06|INFO    TorrentToMedia V8.3
20:15:06|INFO    MAIN: Loading config from C:\Program Files\torrentToMedia\autoProcessMedia.cfg
20:15:06|DEBUG   MAIN: Received Directory: C:\Users\All\Downloads\Seeding\Rain.Man.1988.720p.BluRay.x264-SiNNERS | Name: Rain.Man.1988.720p.BluRay.x264-SiNNERS | Category: movies
20:15:06|INFO    SEARCH: Files appear to be in their own directory
20:15:06|INFO    MAIN: Output directory set to: C:\Users\All\Downloads\Post-Processing\movies\Rain.Man.1988.720p.BluRay.x264-SiNNERS
20:15:06|DEBUG   MAIN: Scanning files in directory: C:\Users\All\Downloads\Seeding\Rain.Man.1988.720p.BluRay.x264-SiNNERS
20:15:06|INFO    MAIN: Found video file .mkv in C:\Users\All\Downloads\Seeding\Rain.Man.1988.720p.BluRay.x264-SiNNERS\Rain.Man.1988.720p.BluRay.x264-SiNNERS.mkv
20:15:06|INFO    CREATE DESTINATION: Creating destination folder: C:\Users\All\Downloads\Post-Processing\movies\Rain.Man.1988.720p.BluRay.x264-SiNNERS
20:15:06|DEBUG   Copying C:\Users\All\Downloads\Seeding\Rain.Man.1988.720p.BluRay.x264-SiNNERS\Rain.Man.1988.720p.BluRay.x264-SiNNERS.mkv to C:\Users\All\Downloads\Post-Processing\movies\Rain.Man.1988.720p.BluRay.x264-SiNNERS\Rain.Man.1988.720p.BluRay.x264-SiNNERS.mkv
20:25:22|INFO    MAIN: Found metadata file .nfo for file C:\Users\All\Downloads\Seeding\Rain.Man.1988.720p.BluRay.x264-SiNNERS\rain.man.1988.720p.bluray.x264-sinners.nfo
20:25:22|DEBUG   Copying C:\Users\All\Downloads\Seeding\Rain.Man.1988.720p.BluRay.x264-SiNNERS\rain.man.1988.720p.bluray.x264-sinners.nfo to C:\Users\All\Downloads\Post-Processing\movies\Rain.Man.1988.720p.BluRay.x264-SiNNERS\rain.man.1988.720p.bluray.x264-sinners.nfo
20:25:22|INFO    FLATTEN: Flattening directory: C:\Users\All\Downloads\Post-Processing\movies\Rain.Man.1988.720p.BluRay.x264-SiNNERS
20:25:22|INFO    REMOVER: Removing empty folders in: C:\Users\All\Downloads\Post-Processing\movies\Rain.Man.1988.720p.BluRay.x264-SiNNERS
20:25:22|DEBUG   MAIN: Connecting to uTorrent: http://localhost:8082/gui/
20:25:22|DEBUG   MAIN: Calling autoProcess script for successful download.
20:25:22|INFO    MAIN: Calling CouchPotatoServer to post-process: Rain.Man.1988.720p.BluRay.x264-SiNNERS
20:25:22|INFO    Loading config from C:\Program Files\torrentToMedia\autoProcessMedia.cfg
20:25:22|WARNING Could not find an imdb id in directory or name
20:25:22|INFO    Postprocessing will continue, but the movie may not be identified correctly by CouchPotato
20:25:22|DEBUG   Opening URL: http://localhost:5050/api/removed/movie.list/?status=active
20:25:40|ERROR   Could not parse database results to determine imdbid or movie id
Traceback (most recent call last):
  File "C:\Users\clinton.hall\Desktop\pyinstaller-2.0\TorrentToMedia\build\pyi.win32\TorrentToMedia\out00-PYZ.pyz\autoProcess.autoProcessMovie", line 68, in get_movie_info
KeyError: 'info'
20:25:40|INFO    Waiting for 65.0 seconds to allow CPS to process newly extracted files
20:26:45|DEBUG   Opening URL: http://localhost:5050/api/removed/renamer.scan
20:32:12|INFO    CouchPotatoServer returned {u'success': True}
20:32:12|INFO    renamer scan started on CouchPotatoServer for Rain.Man.1988.720p.BluRay.x264-SiNNERS
20:34:12|WARNING The movie does not appear to have changed status after 2 minutes. Please check CouchPotato Logs
20:34:12|INFO    MAIN: A problem was reported in the autoProcess* script. If torrent was pasued we will resume seeding
20:34:12|INFO    MAIN: All done.

CPS

09-27 20:26:50 INFO [tato.core.plugins.scanner] Found 1 movies in the folder C:\Users\All\Downloads\Post-Processing\movies09-27 20:26:51 INFO [hpotato.core.plugins.base] Opening url: http://www.omdbapi.com/?i=tt0095953, params: []
09-27 20:26:51 INFO [hpotato.core.plugins.base] Opening url: https://api.couchpota.to/info/tt0095953/, params: []
09-27 20:26:53 INFO [re.providers.info.omdbapi] Found: Rain Man (1988)
09-27 20:26:56 INFO [tato.core.plugins.renamer] Renaming "C:\Users\All\Downloads\Post-Processing\movies\Rain.Man.1988.720p.BluRay.x264-SiNNERS\rain.man.1988.720p.bluray.x264-sinners.nfo" to "G:\External HD\Movies\Rain Man (1988)\Rain Man.orig.nfo"
09-27 20:27:06 INFO [tato.core.plugins.renamer] Renaming "C:\Users\All\Downloads\Post-Processing\movies\Rain.Man.1988.720p.BluRay.x264-SiNNERS\Rain.Man.1988.720p.BluRay.x264-SiNNERS.mkv" to "G:\External HD\Movies\Rain Man (1988)\Rain Man.mkv"
09-27 20:32:01 INFO [tato.core.plugins.renamer] Deleting folder: C:\Users\All\Downloads\Post-Processing\movies\Rain.Man.1988.720p.BluRay.x264-SiNNERS

Any thoughts?

clinton-hall commented 11 years ago

There was a change to the Api calls in CouchPotato. As such, this script was failing to get the imdb id / movie id.

This has been updated recently in dev branch.

Please switch to dev branch and test.

Ok. Just noticed you are using the windows build. If you have python installed you can use the source version on this repo, otherwise I'll try and create another build soon.

jkurelek commented 11 years ago

Alright thanks for clearing that up. I'll try the dev branch and post back here. Cheers

jkurelek commented 11 years ago

OK, tried both the dev and master branches and can't get passed the input args error

08:40:02|INFO    ====================
08:40:02|INFO    TorrentToMedia V8.4
08:40:02|INFO    MAIN: Loading config from C:\TorrentToMediaPy\autoProcessMedia.cfg
08:40:02|ERROR   MAIN: There was a problem loading variables
Traceback (most recent call last):
  File "C:\TorrentToMediaPy\TorrentToMedia.py", line 287, in <module>
    inputDirectory, inputName, inputCategory, inputHash, inputID = parse_args(clientAgent)
  File "C:\TorrentToMediaPy\autoProcess\nzbToMediaUtil.py", line 357, in parse_args
    return parseFunc(sys.argv)
  File "C:\TorrentToMediaPy\autoProcess\nzbToMediaUtil.py", line 307, in parse_utorrent
    inputDirectory = os.path.normpath(args[1])
IndexError: list index out of range

Now I'm likely chalking this one up to python noobness as I'm pretty new to all this. I have Python 2.7.5 installed. In switching from the windows build, I downloaded and unpacked the dev branch zip, updated its autoProcessMedia.cfg and pointed my utorrent at the new script.

utorrent Run Program:

C:\TorrentToMediaPy\TorrentToMedia.py "%D" "%N" "%L" "%I"

What am I doing wrong?

clinton-hall commented 11 years ago

some versions of uTorrent fail to send the first parameter. so try

C:\TorrentToMediaPy\TorrentToMedia.py "%D" "%D" "%N" "%L" "%I"

see if this works.

if not Ill try and create a debug script that will print the args to show what is happening.

jkurelek commented 11 years ago

No dice on adding the extra "%D"

clinton-hall commented 11 years ago

try switching to the newly created debugg branch (with the extra g at the end of debug... it's midnight here :P)

when called this should log all of the variables passed from utorrent.

Just to check here. You are calling the script from uTorrent and not just trying to manually execute this right?

jkurelek commented 11 years ago

That's correct..executing from uTorrent (v3.3.1 for Windows).

Ran the debugging branch:

10:23:37|INFO    TorrentToMedia V8.4
10:23:37|INFO    MAIN: Loading config from C:\nzbToMedia-debugg\autoProcessMedia.cfg
10:23:37|DEBUG   arg 0 is: C:\nzbToMedia-debugg\TorrentToMedia.py
10:23:37|ERROR   MAIN: There was a problem loading variables
Traceback (most recent call last):
  File "C:\nzbToMedia-debugg\TorrentToMedia.py", line 287, in <module>
    inputDirectory, inputName, inputCategory, inputHash, inputID = parse_args(clientAgent)
  File "C:\nzbToMedia-debugg\autoProcess\nzbToMediaUtil.py", line 361, in parse_args
    return parseFunc(sys.argv)
  File "C:\nzbToMedia-debugg\autoProcess\nzbToMediaUtil.py", line 307, in parse_utorrent
    inputDirectory = os.path.normpath(args[1])
IndexError: list index out of range

Looks like it only spit out arg 0 (and is that even suppose to be arg 0?).

As a reminder here is what I have for Run Program in uTorrent:

C:\nzbToMedia-debugg\TorrentToMedia.py "%D" "%N" "%L" "%I"
clinton-hall commented 11 years ago

Yes, arg 0 is the first arg, and this is the full path/name of the script being run. All off the passed args are args 1, 2, 3 etc....

The issue here is that uTorrent doesn't appear to be passing any of the additional arguments. This is what I would expect to see if you just executed the script manually (try this to verify).

So this is an issue with the way uTorrent is calling the script.

clinton-hall commented 11 years ago

Apparently if you right click on the tabs in uTorrent UI, you should be able to select/enable a logger tab. The log for uTorrent should show exactly what command is being called....

clinton-hall commented 11 years ago

Also, if you haven't already, try restarting the uTorrent service

jkurelek commented 11 years ago

From my uTorrent log:

[2013-10-04 10:17:41]  Executing: C:\nzbToMedia-debugg\TorrentToMedia.py "C:\Users\All\Downloads\Seeding\tv" "Its.Always.Sunny.in.Philadelphia.S09E05.HDTV.x264-ASAP.mp4" "tv" "15014D7FB2851FFACE9F8CC234E0020D8845B904"

This is really bizarre...

clinton-hall commented 11 years ago

Thanks... That gives me more to go on... Perhaps it is something I broke.... I'll try adding debug printing elsewhere.

jkurelek commented 11 years ago

Could it be that the issue is with the script picking up the arguments and not with uTorrent? Reason I say this is because (besides the log showing the args getting passed) my uTorrent never had any problem passing arguments to the windows build (exe).

clinton-hall commented 11 years ago

certainly possible. there are some environment differences between the compiled build and the python scripts.... or it could be that I made a change that has killed this function.

If you update to this latest version, this should log the environment variables at the first possible chance to see if these are reaching the script, but then not being passed correctly.

clinton-hall commented 11 years ago

this might also help ensure the args are passed between functions...

jkurelek commented 11 years ago

Updated to latest (both commits) and tested:

17:51:59|INFO    ====================
17:51:59|INFO    TorrentToMedia V8.4
17:51:59|INFO    MAIN: Loading config from C:\nzbToMedia-debugg\autoProcessMedia.cfg
17:51:59|DEBUG   arg 0 is: C:\nzbToMedia-debugg\TorrentToMedia.py
17:51:59|DEBUG   arg 0 is: C:\nzbToMedia-debugg\TorrentToMedia.py
17:51:59|ERROR   MAIN: There was a problem loading variables
Traceback (most recent call last):
  File "C:\nzbToMedia-debugg\TorrentToMedia.py", line 292, in <module>
    inputDirectory, inputName, inputCategory, inputHash, inputID = parse_args(clientAgent, sys.argv)
  File "C:\nzbToMedia-debugg\autoProcess\nzbToMediaUtil.py", line 361, in parse_args
    return parseFunc(sys_args)
  File "C:\nzbToMedia-debugg\autoProcess\nzbToMediaUtil.py", line 307, in parse_utorrent
    inputDirectory = os.path.normpath(args[1])
IndexError: list index out of range
clinton-hall commented 11 years ago

So the issue is that the variables are not getting to the script. This might actually be a limitation with python on windows. I believe RuudBurger had found that args couldn't be passed through the windows build of CouchPotato... But if you call

python script.py args 

Then the args are passed, but

script.py args

Doesn't work...

Can you do a quick test for this?

Looks like the next step might be for me to just compile the dev branch for you to test that ;)

jkurelek commented 11 years ago

I'm not at my computer anymore but I'll do the test when I'm back home later tonight.

And hey, I wouldn't argue with a new windows build :)

clinton-hall commented 11 years ago

V8.5 windows build available from wiki...

I tested, I can't reproduce any issues with passing args from command line... I am wondering if there is something funny with your uTorrent setup.... anyway, try the new build. it might be an incompatibility with uTorrent passing to py...

jkurelek commented 11 years ago

Alright I have updates on many fronts...

  1. v8.5 windows build works beautifully. Thanks for putting that together.
  2. After playing around in the command prompt...I could not find any way to pass arguments to a python script.
script.py arg

vs.

python script.py arg

made no difference. After doing some Googling I was able to figure out the problem that's been plaguing us the whole time: http://stackoverflow.com/questions/2640971/windows-is-not-passing-command-line-arguments-to-python-programs-executed-from-t As it turns out, upon installing python in windows, a setting in missing in the registry to allow passing arguments...lol kind of dumb eh?

Anyways it's all sorted out now. I've since tested with the py version of TorrentToMedia and its working great. Thank you very much Clinton for all your help, I really appreciate it. Cheers!

clinton-hall commented 11 years ago

Ah... That would be why my testing seemed to work.... I have pyinstaller on my windows system (this is the package used to compile python to .exe) and I'm sure this would fix that registry issue.

Glad it is now working.

clinton-hall commented 11 years ago

Closing this for now. Let me know if anything else pops up.