Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overly eager matching of "cd" #742

Open
jcfp opened this issue Mar 6, 2023 · 0 comments
Open

overly eager matching of "cd" #742

jcfp opened this issue Mar 6, 2023 · 0 comments

Comments

@jcfp
Copy link

jcfp commented Mar 6, 2023

hi,

a recent PR of mine (sabnzbd/sabnzbd#2461) had occasional test failures. The function tested uses guessit to detect cd and part in filenames, and for this test was supplied with filenames (also) containing a random hexadecimal string.

It turned out guessit was very eager to match the cd property even in the middle of such strings. The part property on the other hand behaves as expected, i.e. it is only matched if surrounded by some form of spacing or delimiter:

Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import guessit
>>> guessit.__version__
'3.7.1'
>>> guessit.api.guessit("My File 238ddcd5aff.mkv")
MatchesDict([('title', 'My File 238dd'), ('cd', 5), ('container', 'mkv'), ('mimetype', 'video/x-matroska'), ('type', 'movie')])
>>> guessit.api.guessit("My File 238ddpart5aff.mkv")
MatchesDict([('title', 'My File 238ddpart5aff'), ('container', 'mkv'), ('mimetype', 'video/x-matroska'), ('type', 'movie')])
>>> guessit.api.guessit("My File 238dd(part5)aff.mkv")
MatchesDict([('title', 'My File 238dd'), ('part', 5), ('container', 'mkv'), ('mimetype', 'video/x-matroska'), ('type', 'movie')])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants