Skip to content

fix: make both RemoveLessSpecificSeasonEpisode passes execute (#961) - #962

Open
opensubtitles wants to merge 1 commit into
guessit-io:developfrom
opensubtitles:fix-dead-season-rule
Open

fix: make both RemoveLessSpecificSeasonEpisode passes execute (#961)#962
opensubtitles wants to merge 1 commit into
guessit-io:developfrom
opensubtitles:fix-dead-season-rule

Conversation

@opensubtitles

Copy link
Copy Markdown

Fixes #961.

Problem

processors.py registers the same rule class twice:

RemoveLessSpecificSeasonEpisode("season"),
RemoveLessSpecificSeasonEpisode("episode"),

but rebulk's Rule.__eq__/__hash__ compare by class only, so when rebulk objects are merged (extend_safe in effective_rules()) the second instance is silently dropped. Only the ("season") pass has ever executed; the ("episode") pass is dead code. Verifiable on 4.4.0:

from guessit.api import default_api
default_api.guessit('warmup.mkv')
rules = [r for r in default_api.rebulk.effective_rules()
         if type(r).__name__ == 'RemoveLessSpecificSeasonEpisode']
len(rules)  # -> 1, and its predicate closes over "season"

Fix

  • Registration split into two distinct subclasses, RemoveLessSpecificSeason and RemoveLessSpecificEpisode, so both passes survive dedup.
  • Reviving the episode pass exposed one regression in the existing corpus (The.Good.Wife.S06E01.E10.…/The.Good.Wife.S06E09.….mkv — the pack directory's [1, 10] overrode the file's episode 9), so the rule now acts only when one filepart is strictly more SxxExx-specific than the others; equally-specific fileparts fall through to the generic RemoveAmbiguous, whose full-property weight and rightmost preference already pick the correct side.

Same fix shipped in guessit-js (TypeScript port tracking this corpus) where we originally hit the trap.

Tests

Full suite: 2520 passed, 4 skipped (was 1 failure with the naive two-subclass fix, 0 with the specificity guard).

Rule.__eq__/__hash__ in rebulk compare by class only, so when rebulk objects
are merged via extend_safe the second RemoveLessSpecificSeasonEpisode
instance is silently dropped: only the ("season") pass ever ran, and the
("episode") pass was dead code.

Split the registration into two distinct subclasses (RemoveLessSpecificSeason
/ RemoveLessSpecificEpisode) so both passes survive registration, and guard
the rule to act only when one filepart is strictly more SxxExx-specific than
the others. Equally-specific fileparts ("S06E01.E10" pack directory vs
"S06E09" file) are left to the generic RemoveAmbiguous, whose full-property
weight and rightmost preference already pick the correct side.

Fixes guessit-io#961
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RemoveLessSpecificSeasonEpisode('episode') never executes — rebulk dedupes duplicate rule classes

1 participant