[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.
ablitz
Posts: 4
Joined: 09 Dec 2014, 19:33

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

Post by ablitz » 09 Dec 2014, 21:25

minimeh wrote:
ablitz wrote:
hugbug wrote:Is this bad?
The problem for me is that Sickgear specifies that HDTV should contain x264. So it messes up the sorting, I assume the other Sick* forks uses the same rename function.
One of the great aspects of nzbget is DIY customizations.

You can use a text editor to modify your copy of videosort.py to meet your needs. Find the following code:

Code: Select all

    elif guess['type'] == 'episode':
        guess['vtype'] = 'series'
    else:
        guess['vtype'] = guess['type']

    if dnzb_headers:
        apply_dnzb_headers(guess)
and modify it to this:

Code: Select all

    elif guess['type'] == 'episode':
        guess['vtype'] = 'series'
    else:
        guess['vtype'] = guess['type']

    # specialization to accommodate Sickgear
    if guess['videoCodec'] == 'h264':
        guess['videoCodec'] = 'x264'

    if dnzb_headers:
        apply_dnzb_headers(guess)
NOTE: python is very particular about the leading whitespace in the statements. Pay close attention to the existing whitespace and match it. That is, if the indentations are made with tabs, ensure that your patch's indentations are made with tabs. Or if the whitespace is made with spaces, use spaces. And be sure to keep an un-modified copy of vidwosort.py so you can revert if worse comes to worse.
ablitz wrote:Worked perfectly!
Made the changes and it came out as x264 on the same file.
Thanks for the assistance!
Edit: Seems like Videosort now renames everything with h264 to x264, so now web-dl's aren't handled properly.

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

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

Post by minimeh » 10 Dec 2014, 12:16

Yup, that's exactly what the code does: It changes every instance of h264 to x264. It seemed like that's what you were asking for.

If you want to change only when the video format is 'HDTV', then this would work:

Code: Select all

if guess['videoCodec'] == 'h264' and guess['format'] == 'HDTV':
    guess['videoCodec'] = 'x264'
If you have other conditions, this should get you started on it.

ablitz
Posts: 4
Joined: 09 Dec 2014, 19:33

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

Post by ablitz » 15 Dec 2014, 17:27

minimeh wrote:Yup, that's exactly what the code does: It changes every instance of h264 to x264. It seemed like that's what you were asking for.

If you want to change only when the video format is 'HDTV', then this would work:

Code: Select all

if guess['videoCodec'] == 'h264' and guess['format'] == 'HDTV':
    guess['videoCodec'] = 'x264'
If you have other conditions, this should get you started on it.
Thanks for all the help. This got me on the right track and everything is working fine now.

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

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

Post by minimeh » 06 Jan 2015, 10:08

I just ran into another odd-ball case that confounds guessit which leads to errors in videosort.

The file name is "71.2014.720p.Web-Dl.x264.Aac-IFT.mkv". ( See http://www.imdb.com/title/tt2614684/?ref_=nv_sr_2.)

Turning on verbose in videosort, here are the log entries:

Code: Select all

https://dognzb.cr/details/657b60976ec7eba0fee940b7599c250f
Mon Jan 05 23:39:34 2015	INFO	71.2014.720p.Web-Dl.x264.Aac-IFT returned from history back to download queue
Mon Jan 05 23:39:34 2015	INFO	Queueing 71.2014.720p.Web-Dl.x264.Aac-IFT for post-processing
Mon Jan 05 23:39:35 2015	INFO	Checking renamed files for 71.2014.720p.Web-Dl.x264.Aac-IFT
Mon Jan 05 23:39:35 2015	INFO	No renamed files found for 71.2014.720p.Web-Dl.x264.Aac-IFT
Mon Jan 05 23:39:35 2015	INFO	Executing post-process-script videosort\VideoSort.py for 71.2014.720p.Web-Dl.x264.Aac-IFT
Mon Jan 05 23:39:35 2015	INFO	VideoSort: filename: Z:\Media\Movies\71.2014.720p.Web-Dl.x264.Aac-IFT\'71.2014.720p.WEB-DL.x264.AAC-iFT.mkv
Mon Jan 05 23:39:35 2015	INFO	VideoSort: Using NZB-Name
Mon Jan 05 23:39:35 2015	INFO	VideoSort: Guessing: 71.2014.720p.Web-Dl.x264.Aac-IFT.mkv
Mon Jan 05 23:39:35 2015	INFO	VideoSort: 00000000000000000000000000000000 111
Mon Jan 05 23:39:35 2015	INFO	VideoSort: 00000000000000000000000000000000 000
Mon Jan 05 23:39:35 2015	INFO	VideoSort: 00000000000001111112222222222222 000
Mon Jan 05 23:39:35 2015	INFO	VideoSort: 0000000011112      0111122222222
Mon Jan 05 23:39:36 2015	INFO	VideoSort: 00111111                01112222
Mon Jan 05 23:39:36 2015	INFO	VideoSort:   011112
Mon Jan 05 23:39:36 2015	INFO	VideoSort: __.____.____.______.____._______.___
Mon Jan 05 23:39:36 2015	INFO	VideoSort: EE yyyy ssss ffffff vvvv aaaTTTT ccc
Mon Jan 05 23:39:36 2015	INFO	VideoSort: 71.2014.720p.Web-Dl.x264.Aac-IFT.mkv
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'type': u'episode'}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'episodeNumber': 71}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'year': 2014}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'screenSize': u'720p'}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'format': u'WEB-DL'}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'videoCodec': u'h264'}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'audioCodec': u'AAC'}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'series': u'IFT'}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'mimetype': u'video/mkv', u'container': u'mkv'}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {u'container': u'mkv'}
Mon Jan 05 23:39:36 2015	INFO	VideoSort: {
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [1.00] "mimetype": "video/mkv",
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [0.40] "episodeNumber": 71,
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [1.00] "videoCodec": "h264",
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [1.00] "container": "mkv",
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [1.00] "format": "WEB-DL",
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [0.50] "series": "IFT",
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [1.00] "screenSize": "720p",
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [1.00] "year": 2014,
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [1.00] "type": "episode",
Mon Jan 05 23:39:36 2015	INFO	VideoSort:     [1.00] "audioCodec": "AAC"
Mon Jan 05 23:39:36 2015	INFO	VideoSort: }
Mon Jan 05 23:39:36 2015	INFO	VideoSort: Type: series
Mon Jan 05 23:39:37 2015	INFO	VideoSort: format: %sn/Season %s/%s.n.S%0sE%0e.%ext
Mon Jan 05 23:39:37 2015	INFO	VideoSort: path after subst: Ift/Season /Ift.S00E71..mkv
Mon Jan 05 23:39:37 2015	INFO	VideoSort: path after cleanup: Ift\Season\Ift.S00E71.mkv
Mon Jan 05 23:39:37 2015	INFO	VideoSort: destination path: Z:\Media\Movies\Ift\Season\Ift.S00E71.mkv
Mon Jan 05 23:39:37 2015	ERROR	VideoSort: Failed: Autoconsole Lease 700974677999557.nfo
Mon Jan 05 23:39:37 2015	ERROR	VideoSort: [Error 5] Access is denied: u'Z:\\Media\\Movies\\Ift\\Season\\Ift.S00E71.mkv'
Mon Jan 05 23:39:37 2015	INFO	VideoSort: Traceback (most recent call last):
Mon Jan 05 23:39:37 2015	INFO	VideoSort:   File "C:\ProgramData\NZBGet\scripts\videosort\VideoSort.py", line 1140, in <module>
Mon Jan 05 23:39:37 2015	INFO	VideoSort:     new_path = rename(old_path, new_path)
Mon Jan 05 23:39:37 2015	INFO	VideoSort:   File "C:\ProgramData\NZBGet\scripts\videosort\VideoSort.py", line 382, in rename
Mon Jan 05 23:39:37 2015	INFO	VideoSort:     os.remove(new)
Mon Jan 05 23:39:37 2015	INFO	VideoSort: WindowsError: [Error 5] Access is denied: u'Z:\\Media\\Movies\\Ift\\Season\\Ift.S00E71.mkv'
Mon Jan 05 23:39:37 2015	ERROR	Post-process-script videosort\VideoSort.py for 71.2014.720p.Web-Dl.x264.Aac-IFT failed
Mon Jan 05 23:39:37 2015	INFO	Collection 71.2014.720p.Web-Dl.x264.Aac-IFT added to history
I was going to report this to the guessit developers and discovered that it was already reported: "Shows that start with a number are not parsed correctly" (https://github.com/wackou/guessit/issues/181).

Since the developer says that the bug is related to another that is 3 months old, I patched my copy of videosort.py to work around it. When a title begins with 2 digits, I prepend a leading 0 and guessit is happy. Then after guessit returns, I remove the leading 0 from the title.

Here's my patch around line 959:

Code: Select all

    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:]
With this patch, here are the log entries:

Code: Select all

Tue Jan 06 01:43:03 2015	INFO	Executing post-process-script videosort\VideoSort.py for 71 2014 720p Web-Dl x264 Aac-IFT
Tue Jan 06 01:43:03 2015	INFO	VideoSort: filename: Z:\Media\Movies\71 2014 720p Web-Dl x264 Aac-IFT\'71.2014.720p.WEB-DL.x264.AAC-iFT.mkv
Tue Jan 06 01:43:03 2015	INFO	VideoSort: Using NZB-Name
Tue Jan 06 01:43:03 2015	INFO	VideoSort: Guessing: 71 2014 720p Web-Dl x264 Aac-IFT.mkv
Tue Jan 06 01:43:03 2015	INFO	VideoSort: 000000000000000000000000000000000 111
Tue Jan 06 01:43:03 2015	INFO	VideoSort: 000000000000000000000000000000000 000
Tue Jan 06 01:43:03 2015	INFO	VideoSort: 000000000000001111112222222222222 000
Tue Jan 06 01:43:03 2015	INFO	VideoSort: 00000000011112      0111122222222
Tue Jan 06 01:43:04 2015	INFO	VideoSort: 000011112                01112222
Tue Jan 06 01:43:04 2015	INFO	VideoSort:                              0111
Tue Jan 06 01:43:04 2015	INFO	VideoSort: ________ ____ ______ ____ ___-___.___
Tue Jan 06 01:43:04 2015	INFO	VideoSort: ttttyyyy ssss ffffff vvvv aaa rrr ccc
Tue Jan 06 01:43:04 2015	INFO	VideoSort: 071 2014 720p Web-Dl x264 Aac-IFT.mkv
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'type': u'movie'}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'title': u'071'}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'year': 2014}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'screenSize': u'720p'}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'format': u'WEB-DL'}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'videoCodec': u'h264'}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'audioCodec': u'AAC'}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'releaseGroup': u'IFT'}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'mimetype': u'video/mkv', u'container': u'mkv'}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {u'container': u'mkv'}
Tue Jan 06 01:43:04 2015	INFO	VideoSort: {
Tue Jan 06 01:43:04 2015	INFO	VideoSort:     [1.00] "mimetype": "video/mkv",
Tue Jan 06 01:43:04 2015	INFO	VideoSort:     [1.00] "videoCodec": "h264",
Tue Jan 06 01:43:04 2015	INFO	VideoSort:     [1.00] "container": "mkv",
Tue Jan 06 01:43:04 2015	INFO	VideoSort:     [1.00] "format": "WEB-DL",
Tue Jan 06 01:43:04 2015	INFO	VideoSort:     [0.60] "title": "071",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "releaseGroup": "IFT",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "screenSize": "720p",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "year": 2014,
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "type": "movie",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "audioCodec": "AAC"
Tue Jan 06 01:43:05 2015	INFO	VideoSort: }
Tue Jan 06 01:43:05 2015	INFO	VideoSort: Using DNZB-ProperName
Tue Jan 06 01:43:05 2015	INFO	VideoSort: Using DNZB-MovieYear
Tue Jan 06 01:43:05 2015	INFO	VideoSort: Using DNZB-MoreInfo
Tue Jan 06 01:43:05 2015	INFO	VideoSort: {
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "mimetype": "video/mkv",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "videoCodec": "h264",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "container": "mkv",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "format": "WEB-DL",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "cpimdb": "cp(tt2614684)",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "releaseGroup": "IFT",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "vtype": "movie",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "imdb": "tt2614684",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "screenSize": "720p",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "year": "2014",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [0.60] "title": "71",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "type": "movie",
Tue Jan 06 01:43:05 2015	INFO	VideoSort:     [1.00] "audioCodec": "AAC"
Tue Jan 06 01:43:05 2015	INFO	VideoSort: }
Tue Jan 06 01:43:05 2015	INFO	VideoSort: Type: movie
Tue Jan 06 01:43:05 2015	INFO	VideoSort: format: %t (%y)/%t (%y).%ext
Tue Jan 06 01:43:05 2015	INFO	VideoSort: path after subst: 71 (2014)/71 (2014)..mkv
Tue Jan 06 01:43:05 2015	INFO	VideoSort: path after cleanup: 71 (2014)\71 (2014).mkv
Tue Jan 06 01:43:06 2015	INFO	VideoSort: destination path: Z:\Media\Movies\71 (2014)\71 (2014).mkv
Tue Jan 06 01:43:06 2015	INFO	VideoSort: Moved: Z:\Media\Movies\71 (2014)\71 (2014).mkv
Tue Jan 06 01:43:06 2015	INFO	VideoSort: Move satellites for Z:\Media\Movies\71 2014 720p Web-Dl x264 Aac-IFT\'71.2014.720p.WEB-DL.x264.AAC-iFT.mkv
Tue Jan 06 01:43:06 2015	INFO	Post-process-script videosort\VideoSort.py for 71 2014 720p Web-Dl x264 Aac-IFT successful
This will work for me until the guessit bug is fixed.

NOTE: Anybody who wants to patch their copy of videosort.py, be sure that the leading white space of the modifications matches the rest of the file. That is, if tabs are used for white space, ensure that you use tabs. Conversely, if spaces are used, ensure that you use spaces. Python is very picky about this. And always keep a pristine backup copy so you can revert to it if worse comes to worse.

[EDIT}
Made a correction to patch for when a TV series starts with 2 digits, e.g. "12 Monkeys".
Last edited by minimeh on 24 Jan 2015, 22:26, edited 1 time in total.

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

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

Post by hugbug » 06 Jan 2015, 15:03

Thanks.

BTW why it fails with that path - what's so bad about it?

Code: Select all

Mon Jan 05 23:39:37 2015   INFO   VideoSort: destination path: Z:\Media\Movies\Ift\Season\Ift.S00E71.mkv
Mon Jan 05 23:39:37 2015   ERROR   VideoSort: Failed: Autoconsole Lease 700974677999557.nfo
Mon Jan 05 23:39:37 2015   ERROR   VideoSort: [Error 5] Access is denied: u'Z:\\Media\\Movies\\Ift\\Season\\Ift.S00E71.mkv'
Mon Jan 05 23:39:37 2015   INFO   VideoSort: Traceback (most recent call last):
Mon Jan 05 23:39:37 2015   INFO   VideoSort:   File "C:\ProgramData\NZBGet\scripts\videosort\VideoSort.py", line 1140, in <module>
Mon Jan 05 23:39:37 2015   INFO   VideoSort:     new_path = rename(old_path, new_path)
Mon Jan 05 23:39:37 2015   INFO   VideoSort:   File "C:\ProgramData\NZBGet\scripts\videosort\VideoSort.py", line 382, in rename
Mon Jan 05 23:39:37 2015   INFO   VideoSort:     os.remove(new)
Mon Jan 05 23:39:37 2015   INFO   VideoSort: WindowsError: [Error 5] Access is denied: u'Z:\\Media\\Movies\\Ift\\Season\\Ift.S00E71.mkv'

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

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

Post by minimeh » 06 Jan 2015, 19:30

That's a good question that I was wondering myself! All paths listed did exist and were created by nzbget itself. I didn't have any of the files locked in another process.

I don't know the answer.

krazypoloc
Posts: 1
Joined: 13 Jan 2015, 15:13

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

Post by krazypoloc » 13 Jan 2015, 15:27

I think I've been able to configure the PP Script on everything but 1 issue.

How do I get parenthesis around the year in the show name for the top level folder?
Example.
The Librarians 2014
Should be
The Librarians (2014)

This is what I currently have.
%sn (%y)/Season %0s/%s.n.S%0sE%0e.%e.n

ressof
Posts: 6
Joined: 21 Aug 2014, 07:03

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

Post by ressof » 15 Jan 2015, 06:37

Hello

I wonder if the script passes any variables to get the new file location to use with scrips running after VideoSort?

kloaknet
Posts: 337
Joined: 23 Jul 2014, 08:52

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

Post by kloaknet » 15 Jan 2015, 16:58

ressof wrote:Hello

I wonder if the script passes any variables to get the new file location to use with scrips running after VideoSort?
I suppose you need to use the 'listgroups' FinalDir option from this: http://nzbget.net/RPC_API_reference#Met ... tgroups.22

kloaknet
Posts: 337
Joined: 23 Jul 2014, 08:52

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

Post by kloaknet » 17 Jan 2015, 09:47

Because the more obfuscated post lately, I noticed that the option PreferNZBName doesn't make it use the nzb name.
Also the indexer sends the DNZB info with it, like:

Code: Select all

[{u'Name': u'*DNZB:Site', u'Value': u'INDEXER'}, {u'Name': u'*DNZB:Name', u'Value': u'The.Wait.2013.LIMITED.DVDRip.x264-BiPOLAR'}, {u'Name': u'*DNZB:Link', u'Value': u'INDEXER/details/9f9eb2e19c9eb11de9937b589cc9b797'}, {u'Name': u'*DNZB:Details', u'Value': u'INDEXER/details/9f9eb2e19c9eb11de9937b589cc9b797'}, {u'Name': u'*DNZB:NFO', u'Value': u'INDEXER/api?t=getnfo&id=9f9eb2e19c9eb11de9937b589cc9b797&raw=1&i=ID&r=APIKEY'}, {u'Name': u'*DNZB:Report', u'Value': u'INDEXER/report/9f9eb2e19c9eb11de9937b589cc9b797/APIKEY'}, {u'Name': u'*DNZB:Failure', u'Value': u'INDEXER/fail/9f9eb2e19c9eb11de9937b589cc9b797/APIKEY'}, {u'Name': u'*DNZB:ProperName', u'Value': u'The Wait'}, {u'Name': u'*DNZB:MovieYear', u'Value': u'2013'}, {u'Name': u'*DNZB:MoreInfo', u'Value': u'http://www.imdb.com/title/tt1675759'}, {u'Name': u'*DNZB:RCode', u'Value': u'200'}, {u'Name': u'*DNZB:RText', u'Value': u'OK, NZB content follows'}
Note that I have the option SeriesFormat set to: %sN/%fn, so I guess this overrules the PreferNZBName option?

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests