[PP-Script] VideoSort - better video sorting

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
barabbas
Posts: 27
Joined: 04 Dec 2014, 17:35

Re: [PP-Script] VideoSort - better video sorting

Post by barabbas » 24 Jan 2015, 19:46

For some reason VideoSort seems to think that 22 Jump street is a tv show:

Code: Select all

Sat Jan 24 20:47:36 2015	INFO	Executing post-process-script videosort/VideoSort.py for 22.Jump.Street.2014.720p.BRRiP.XViD.AC3-LEGi0N
Sat Jan 24 20:47:36 2015	INFO	VideoSort: Traceback (most recent call last):
Sat Jan 24 20:47:36 2015	INFO	VideoSort:   File "/home/x/.config/nzbget/scripts/videosort/VideoSort.py", line 1129, in <module>
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     new_path = construct_path(old_path)
Sat Jan 24 20:47:36 2015	INFO	VideoSort:   File "/home/x/.config/nzbget/scripts/videosort/VideoSort.py", line 1016, in construct_path
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     guess = guess_info(filename)
Sat Jan 24 20:47:36 2015	INFO	VideoSort:   File "/home/x/.config/nzbget/scripts/videosort/VideoSort.py", line 981, in guess_info
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     last_node.guess.get('series') != None and guess['season'] != guess['year']:
Sat Jan 24 20:47:36 2015	INFO	VideoSort: KeyError: 'season'
Sat Jan 24 20:47:36 2015	INFO	VideoSort: Skipping small: 22.Jump.Street.2014.720p.BRRiP.XViD.AC3-LEGi0N.sample.avi
Sat Jan 24 20:47:36 2015	INFO	VideoSort: filename: /home/x/temp/22.Jump.Street.2014.720p.BRRiP.XViD.AC3-LEGi0N/22.Jump.Street.2014.720p.BRRiP.XViD.AC3-LEGi0N.avi
Sat Jan 24 20:47:36 2015	INFO	VideoSort: Using NZB-Name
Sat Jan 24 20:47:36 2015	INFO	VideoSort: Guessing: 22.Jump.Street.2014.720p.BRRiP.XViD.AC3-LEGi0N.avi
Sat Jan 24 20:47:36 2015	INFO	VideoSort: 0000000000000000000000000000000000000000000000 111
Sat Jan 24 20:47:36 2015	INFO	VideoSort: 0000000000000000000000000000000000000000000000 000
Sat Jan 24 20:47:36 2015	INFO	VideoSort: 0000000000000000000000000111112222222222222222 000
Sat Jan 24 20:47:36 2015	INFO	VideoSort: 0000000000000000000011112     0111122222222222
Sat Jan 24 20:47:36 2015	INFO	VideoSort: 00111111111111111111               01112222222
Sat Jan 24 20:47:36 2015	INFO	VideoSort:   000000000000011112                   0111111
Sat Jan 24 20:47:36 2015	INFO	VideoSort: ___________________.____._____.____.___-______.___
Sat Jan 24 20:47:36 2015	INFO	VideoSort: EETTTTTTTTTTTTTyyyy ssss fffff vvvv aaa rrrrrr ccc
Sat Jan 24 20:47:36 2015	INFO	VideoSort: 22.Jump.Street.2014.720p.BRRiP.XViD.AC3-LEGi0N.avi
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'type': u'episode'}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'episodeNumber': 22}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'series': u'Jump Street'}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'year': 2014}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'screenSize': u'720p'}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'format': u'BluRay'}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'videoCodec': u'XviD'}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'audioCodec': u'AC3'}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'releaseGroup': u'LEGi0N'}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'mimetype': u'video/x-msvideo', u'container': u'avi'}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {u'container': u'avi'}
Sat Jan 24 20:47:36 2015	INFO	VideoSort: {
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [1.00] "mimetype": "video/x-msvideo",
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [0.40] "episodeNumber": 22,
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [1.00] "videoCodec": "XviD",
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [1.00] "container": "avi",
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [1.00] "format": "BluRay",
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [0.50] "series": "Jump Street",
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [1.00] "releaseGroup": "LEGi0N",
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [1.00] "screenSize": "720p",
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [1.00] "year": 2014,
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [1.00] "type": "episode",
Sat Jan 24 20:47:36 2015	INFO	VideoSort:     [1.00] "audioCodec": "AC3"
Sat Jan 24 20:47:36 2015	INFO	VideoSort: }
Sat Jan 24 20:47:36 2015	ERROR	VideoSort: Failed: 22.Jump.Street.2014.720p.BRRiP.XViD.AC3-LEGi0N.avi
Sat Jan 24 20:47:36 2015	ERROR	VideoSort: 'season'
or is that due to my configuration?

hugbug
Developer & Admin
Posts: 7541
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] VideoSort - better video sorting

Post by hugbug » 24 Jan 2015, 19:51

barabbas wrote:or is that due to my configuration?
It's not your config, it's the guessit library (used by the script).
Will see how to fix the crash at least.

minimeh
Posts: 33
Joined: 16 Aug 2013, 09:54

Re: [PP-Script] VideoSort - better video sorting

Post by minimeh » 24 Jan 2015, 20:07

hugbug wrote:
barabbas wrote:or is that due to my configuration?
It's not your config, it's the guessit library (used by the script).
Will see how to fix the crash at least.
I just dl'd "22 Jump Street 2014 1080p BluRay x264 YIFY" and had no problems with VideoSort patched as described in the post: http://nzbget.net/forum/viewtopic.php?p=11448#p11448

barabbas
Posts: 27
Joined: 04 Dec 2014, 17:35

Re: [PP-Script] VideoSort - better video sorting

Post by barabbas » 24 Jan 2015, 22:04

Thanks minimeh, could you post a couple of lines more? I am not 100% which lines to actually replace. Would it look like this:

Code: Select all

    if use_nzb_name:
        if verbose:
            print("Using NZB-Name")
        guessfilename = os.path.basename(download_dir) + os.path.splitext(filename)[1]
    else:
        guessfilename = deobfuscate_path(filename)

    if verbose:
        print('Guessing: %s' % guessfilename)
	bPadStartDigits=(guessfilename[0].isdigit() and guessfilename[1].isdigit())
    if bPadStartDigits:
        guessfilename = '0' + guessfilename

    # matcher = guessit.matcher.IterativeMatcher(unicode(guessfilename), filetype='autodetect', opts=['nolanguage', 'nocountry'])
    matcher = guessit.matcher.IterativeMatcher(unicode(guessfilename), filetype='autodetect', options={'nolanguage': True, 'nocountry': True})
    mtree = matcher.match_tree
    guess = matcher.matched()

    if verbose:
        print(mtree)
        for node in mtree.nodes():
            if node.guess:
                print(node.guess)
        print(guess.nice_string())

    # fix some strange guessit guessing:
    if bPadStartDigits:
        guess['title'] = guess['title'][1:]
    # if guessit doesn't find a year in the file name it thinks it is episode,
    # but we prefer it to be handled as movie instead
    if guess.get('type') == 'episode' and guess.get('episodeNumber', '') == '':
        guess['type'] = 'movie'
        guess['title'] = guess.get('series')
        guess['year'] = '1900'
        if verbose:
            print('episode without episodeNumber is a movie')
            print(guess.nice_string())

minimeh
Posts: 33
Joined: 16 Aug 2013, 09:54

Re: [PP-Script] VideoSort - better video sorting

Post by minimeh » 24 Jan 2015, 22:57

barabbas wrote:Thanks minimeh, could you post a couple of lines more? I am not 100% which lines to actually replace. Would it look like this:
You got the placement right but you have one mistake. Additionally, I just fixed a bug with my patch (the original post has been corrected).

The mistake that you have is at the line

Code: Select all

   bPadStartDigits=(guessfilename[0].isdigit() and guessfilename[1].isdigit())
Notice that the indentation is off by a space. Python won't like that.

The correction that I made to my patch accommodates TV series that begin with 2 digits, e.g. "12 Monkeys".

If you replace your code block with the following, you should be good. As noted before, the leading white space in the patch must match your copy of videosort.py, so you may have to convert spaces to tabs or tabs to spaces.

Code: Select all

    if use_nzb_name:
        if verbose:
            print("Using NZB-Name")
        guessfilename = os.path.basename(download_dir) + os.path.splitext(filename)[1]
    else:
        guessfilename = deobfuscate_path(filename)

    if verbose:
        print('Guessing: %s' % guessfilename)
    bPadStartDigits=(guessfilename[0].isdigit() and guessfilename[1].isdigit())
    if bPadStartDigits:
        guessfilename = '0' + guessfilename

    # matcher = guessit.matcher.IterativeMatcher(unicode(guessfilename), filetype='autodetect', opts=['nolanguage', 'nocountry'])
    matcher = guessit.matcher.IterativeMatcher(unicode(guessfilename), filetype='autodetect', options={'nolanguage': True, 'nocountry': True})
    mtree = matcher.match_tree
    guess = matcher.matched()

    if verbose:
        print(mtree)
        for node in mtree.nodes():
            if node.guess:
                print(node.guess)
        print(guess.nice_string())

    # fix some strange guessit guessing:
    if bPadStartDigits:
        if guess['type'] == 'episode':
            guess['series'] = guess['series'][1:]
        else:
            guess['title'] = guess['title'][1:]
    # if guessit doesn't find a year in the file name it thinks it is episode,
    # but we prefer it to be handled as movie instead
    if guess.get('type') == 'episode' and guess.get('episodeNumber', '') == '':
        guess['type'] = 'movie'
        guess['title'] = guess.get('series')
        guess['year'] = '1900'
        if verbose:
            print('episode without episodeNumber is a movie')
            print(guess.nice_string())

barabbas
Posts: 27
Joined: 04 Dec 2014, 17:35

Re: [PP-Script] VideoSort - better video sorting

Post by barabbas » 25 Jan 2015, 12:29

Thanks! Got it working. Indentation based structure is great when writing python but it's a nightmare when mixing different sources.

CaptainHero
Posts: 19
Joined: 04 Feb 2015, 19:03

Re: [PP-Script] VideoSort - better video sorting

Post by CaptainHero » 04 Feb 2015, 19:19

Hi,

First off i really like this PP-Script however it seems to cause me some issues regarding the permissions of the moved files and folders. I hope someone can help me with this as i would like to keep using videosort for my purposes.

Here's the rundown of my issue:

Currently i have NZBGet setup to run pp script CFP file permission (sets the permissions of my downloads to owner/group: admin/everyone. Folder and file permissions to: 777) which works as intended without issue.

Next NzbGet runs Videosort to rename the downloaded movie file and folder and move it to my movies folder. This is done as intended however i noticed that folder permissions are changed to 755 and the owner/group is changed back to root/root. This is causing the problem since now my other programs (which are not running on my NAS) but connect via network through windows for instance do not have write permissions to the folder anymore so i have to again manually set the folder permission back to 777 via FileZilla for instance to be able to move, delete the folder or to write new files (metadata etc) into the folder.

Any and all help or suggestions how to fix this would be appriciated!

Thank you!

hugbug
Developer & Admin
Posts: 7541
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] VideoSort - better video sorting

Post by hugbug » 05 Feb 2015, 19:49

VideoSort doesn't move/rename folders. It creates destination folders if necessary (which are named according to formatting rules) and then moves/renames files there.

This basically means the permissions for newly created folders are not set to what you expect.

VideoSort uses function "os.makedirs" to create directories, which according to docs sets mode to "0777" but masks it with current UMask.

Try to change option UMask in NZBGet (set it to 000). Since VideoSort is executed by NZBGet it should inherit the UMask and that should help.

CaptainHero
Posts: 19
Joined: 04 Feb 2015, 19:03

Re: [PP-Script] VideoSort - better video sorting

Post by CaptainHero » 05 Feb 2015, 20:18

Thanks for the suggestion. It worked like a charm! :)

passie
Posts: 10
Joined: 14 Feb 2015, 10:03

Re: [PP-Script] VideoSort - better video sorting

Post by passie » 14 Feb 2015, 10:10

I'm pulling my hair out ;-)

I have installed videosort but it's not successful every time I run it.
I have not changed much with the settings besides the MoviesFormat which is now %t (%y)/%t (%y)

My DestDir is /volume1/downloads/postproces and my MoviesDir is /volume1/Movies.

I downloaded 2 test movies
1 is successful and the other isn't
The one failing is giving me the following message:

Code: Select all

INFO	Sat Feb 14 2015 10:56:29	Post-process-script videosort/VideoSort.py for The Captive (2014) successful
WARNING	Sat Feb 14 2015 10:56:29	VideoSort: Skipping clean up due to large files remaining in the directory
INFO	Sat Feb 14 2015 10:56:29	VideoSort: Moved: /volume1/Movies/The Captive (2014)/The Captive (2014).iso
INFO	Sat Feb 14 2015 10:56:25	Executing post-process-script videosort/VideoSort.py for The Captive (2014)
INFO	Sat Feb 14 2015 10:56:25	Move for The Captive (2014) successful
The one successful is giving me the following message:

Code: Select all

INFO	Sat Feb 14 2015 11:07:48	Post-process-script videosort/VideoSort.py for Met grote blijdschap (2001) successful
INFO	Sat Feb 14 2015 11:07:48	VideoSort: Deleted: /volume1/Movies/Met grote blijdschap (2001)
INFO	Sat Feb 14 2015 11:07:48	VideoSort: Deleted: /volume1/Movies/Met grote blijdschap (2001)/met grote blijdschap/met grote blijdschap.txt
INFO	Sat Feb 14 2015 11:07:48	VideoSort: Deleted: /volume1/Movies/Met grote blijdschap (2001)/met grote blijdschap/met grote blijdschap.jpg
INFO	Sat Feb 14 2015 11:07:48	VideoSort: Moved: /volume1/Movies/Met Grote Blijdschap (2001)/Met Grote Blijdschap (2001).avi
Any help is appreciated

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests