Page 1 of 1

GuessIt Property Customization

Posted: June 14th, 2025, 9:28 am
by thunder121
I'm running v4.5.1 on a windows machine and am using the Sorting function to rename files. I'd like to specify a different property result than what is given by default. (e.g. for property 'video_codec' use "x264" instead of "h.264" as the result used in the function.

options.json in \SABnzbd\guessit\config only has a portion of the patterns & associated results listed. (e.g. has 'audio_codec' patterns listed but not 'video_codec'). I am able to successfully modify the result for patterns listed in options.json but not able to add any which are missing.

I've also tried modifying the yml files under \SABnzbd\guessit\test\rules but this was not successful. I've not been able to find any other GuessIt config or rule files to modify.

Any help is greatly appreciated. Thanks!

Re: GuessIt Property Customization

Posted: June 15th, 2025, 4:50 am
by sander
I'm no expert at all, and I haven't got an answer, but I would start by pure python code.

So:

Code: Select all

$ python3
Python 3.13.3 (main, Apr  8 2025, 19:55:40) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import guessit

>>> guessit.guessit("Treme.1x03.Right.Place,.Wrong.Time.HDTV.x264-NoTV.avi")
MatchesDict({'title': 'Treme', 'season': 1, 'episode': 3, 'episode_title': 'Right Place, Wrong Time', 'source': 'HDTV', 'video_codec': 'H.264', 'release_group': 'NoTV', 'container': 'avi', 'mimetype': 'video/x-msvideo', 'type': 'episode'})

And you want to change that 'video_codec': 'H.264' to x264 ...?

Code: Select all

>>> i = guessit.guessit("Treme.1x03.Right.Place,.Wrong.Time.HDTV.x264-NoTV.avi")
>>> i
MatchesDict({'title': 'Treme', 'season': 1, 'episode': 3, 'episode_title': 'Right Place, Wrong Time', 'source': 'HDTV', 'video_codec': 'H.264', 'release_group': 'NoTV', 'container': 'avi', 'mimetype': 'video/x-msvideo', 'type': 'episode'})

>>> i = guessit.guessit("Treme.1x03.Right.Place,.Wrong.Time.HDTV.x264-NoTV.avi")
>>> if i['video_codec'] == 'H.264':
...     i['video_codec']='x264'
...      
>>> 
>>> i
MatchesDict({'title': 'Treme', 'season': 1, 'episode': 3, 'episode_title': 'Right Place, Wrong Time', 'source': 'HDTV', 'video_codec': 'x264', 'release_group': 'NoTV', 'container': 'avi', 'mimetype': 'video/x-msvideo', 'type': 'episode'})


If you want that: run SABnzbd from source code, and add a line in SABnzbd, after getting the resul from guessit() ?