Summary
Post-processing can abort with guessit.api.GuessitException / ValueError: list.remove(x): x not in list when a release folder name ends with a codec/quality suffix that looks like "separator + digits" (classic example: AC-3).
This is a Medusa custom-rules bug, not an upstream Guessit parser failure: stock Guessit parses the same string successfully.
Root cause (generic)
FixParentFolderReplacingTitle treats any parent folder matching (_|\W)\d+$ as "folder ends with a number" (intended for cases like /Comedy 23/Show.S01E01.mkv).
- That regex also matches technical tails such as
AC-3 (-3).
- The rule then mutates an existing match in place:
episode_title[0].name = 'title'
without properly removing/re-adding it in rebulk's indexes → _name_dict desync.
- A later rule (
AvoidMultipleValuesRule, consequence RemoveMatch) calls matches.remove(match) → ValueError: list.remove(x): x not in list → wrapped as GuessitException.
NameParser / _analyze_name only catches InvalidNameException / InvalidShowException, so the exception bubbles up and kills the post-processor for that item.
Generic formula: in-place match.name mutation in Medusa rules + subsequent RemoveMatch = Guessit crash. Frequent trigger = false positive of ends_with_digit on codec/channel suffixes.
Reproduction
Path shape (folder + file both end with AC-3):
tv\Capital - Des vacances de rêve 30 % moins chères, oui, c'est vraiment possible ! 2023 French HDTV 720p AVC MKV AC-3\Capital - Des vacances de rêve 30 % moins chères, oui, c'est vraiment possible ! 2023 French HDTV 720p AVC MKV AC-3.mkv
Observed with Medusa's customized Guessit API (medusa.name_parser.rules); plain guessit.guessit(...) without Medusa rules does not crash.
Confirmed locally:
- Enabling Medusa
rules() → crash
- Culprit interaction:
FixParentFolderReplacingTitle then AvoidMultipleValuesRule
- Skipping
FixParentFolderReplacingTitle when the folder ends with a codec-like suffix → parse succeeds (title=Capital)
Suggested fix
In medusa/name_parser/rules/rules.py (FixParentFolderReplacingTitle):
- Do not treat codec/channel tails as "ends with digit" (
AC-3, EAC3, DDP5.1, H.264, x265, …).
- Prefer not mutating
match.name in place; use proper remove/append so rebulk indexes stay consistent.
Optional hardening:
- Catch
GuessitException in the name parser and map it to InvalidNameException so one bad name cannot abort the whole post-process run.
Environment
- Guessit 3.4.2 (vendored)
- Medusa custom rules in
medusa/name_parser/rules/rules.py
- Log excerpt:
POSTPROCESSOR :: Exception generated: An internal error has occured in guessit. / ValueError: list.remove(x): x not in list in ext/rebulk/match.py
Summary
Post-processing can abort with
guessit.api.GuessitException/ValueError: list.remove(x): x not in listwhen a release folder name ends with a codec/quality suffix that looks like "separator + digits" (classic example:AC-3).This is a Medusa custom-rules bug, not an upstream Guessit parser failure: stock Guessit parses the same string successfully.
Root cause (generic)
FixParentFolderReplacingTitletreats any parent folder matching(_|\W)\d+$as "folder ends with a number" (intended for cases like/Comedy 23/Show.S01E01.mkv).AC-3(-3)._name_dictdesync.AvoidMultipleValuesRule, consequenceRemoveMatch) callsmatches.remove(match)→ValueError: list.remove(x): x not in list→ wrapped asGuessitException.NameParser/_analyze_nameonly catchesInvalidNameException/InvalidShowException, so the exception bubbles up and kills the post-processor for that item.Generic formula: in-place
match.namemutation in Medusa rules + subsequentRemoveMatch= Guessit crash. Frequent trigger = false positive ofends_with_digiton codec/channel suffixes.Reproduction
Path shape (folder + file both end with
AC-3):Observed with Medusa's customized Guessit API (
medusa.name_parser.rules); plainguessit.guessit(...)without Medusa rules does not crash.Confirmed locally:
rules()→ crashFixParentFolderReplacingTitlethenAvoidMultipleValuesRuleFixParentFolderReplacingTitlewhen the folder ends with a codec-like suffix → parse succeeds (title=Capital)Suggested fix
In
medusa/name_parser/rules/rules.py(FixParentFolderReplacingTitle):AC-3,EAC3,DDP5.1,H.264,x265, …).match.namein place; use proper remove/append so rebulk indexes stay consistent.Optional hardening:
GuessitExceptionin the name parser and map it toInvalidNameExceptionso one bad name cannot abort the whole post-process run.Environment
medusa/name_parser/rules/rules.pyPOSTPROCESSOR :: Exception generated: An internal error has occured in guessit./ValueError: list.remove(x): x not in listinext/rebulk/match.py