Benni-chan / nzbToAniDB

postprocessing script for animes (to use with sabnzbd+ or nzbget or even as stand alone) to rename files after a sync with anidb.net. files can additionally be renamed via tvdb
24 stars 7 forks source link

Invalid file #2

Closed heksesang closed 12 years ago

heksesang commented 12 years ago

I keep getting "Invalid file" reported when running the script as a post-script of SABnzbd (with TV sorting disabled).

By the looks of it, SAB passes in the directory to the script, but the os.access fails even though I tested using os.access before the anidb.py script was run (did it from within the sabtoanidb.py script) and it returned true.

It might be because the argument passed in does not have escaped backslashes, and therefore it fails. I'm gonna test that later.

PS: This is on Windows 7 (x64).

heksesang commented 12 years ago

Possibly the lack of escaped backslashes could be explained by the use of non-posix shlex.split? As I don't think it handles escaping the same way in that mode?

heksesang commented 12 years ago
    name = remaining.popleft()
    if not os.access(name, os.R_OK):
        print('{0} {1}'.format(red('Invalid file:'), name))

Seems that name has ' at each side, messing up the os.access and os.path calls.

heksesang commented 12 years ago
    name = remaining.popleft()
    name = name.replace("'", "")
    if not os.access(name, os.R_OK):
        print('{0} {1}'.format(red('Invalid file:'), name))

That should do the trick.

Benni-chan commented 12 years ago

fixed per pull from heksesang