Fix/season pack episode count#596
Conversation
fix(anime): handle list imdb_id from Fribb
WalkthroughThree independent improvements: ChangesTitle Matching and Episode Normalization
Anime Fribb imdb_id List Support
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comet/services/anime.py`:
- Around line 540-556: The fan-out in the Fribb import path is creating multiple
scalar IMDb rows for one entry without adjusting the reverse lookup contract.
Update the logic around the Fribb batch append in comet/services/anime.py and
the get_imdb_from_kitsu() lookup so Kitsu→IMDb remains deterministic for
multi-season records: either preserve a single canonical IMDb per entry_id in
anime_ids, or make the reverse lookup return and merge all matching IMDb IDs
explicitly instead of relying on a scalar LIMIT 1 join. Ensure the stream path
no longer selects an arbitrary season IMDb ID.
In `@comet/services/filtering.py`:
- Around line 41-45: The title parsing in `is_releasable_torrent` is splitting
on every slash, which breaks canonical titles like `Fate/stay night` into
unrelated fragments. Update the slash handling so only separator slashes are
treated as split points, and keep intact title-like slashes from being fed into
`title_match`. Use the existing `torrent_title` processing block and
`title_match` call site to adjust the segmentation logic without reintroducing
the normal title-mismatch path.
In `@comet/utils/parsing.py`:
- Around line 26-29: The completion check in parsing logic is too permissive
because it only compares the first captured count from _EPISODE_COUNT_PACK
against parsed.episodes[0]. Update the normalization in the parsing function so
the title’s two counts must both match the parsed episode count before setting
parsed.complete to True and clearing parsed.episodes. Use the existing match
handling around _EPISODE_COUNT_PACK and the parsed.episodes/parsed.complete
fields to keep partial packs from being marked complete.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 86686fc2-54c1-4828-9e18-9e5c7268df2d
📒 Files selected for processing (3)
comet/services/anime.pycomet/services/filtering.pycomet/utils/parsing.py
| imdb_ids = imdb_id if isinstance(imdb_id, list) else [imdb_id] | ||
|
|
||
| for provider, key in _FRIBB_PROVIDER_ORDER: | ||
| val = entry.get(key) | ||
| if val: | ||
| found_entry_id = lookup_map.get(f"{provider}:{val}") | ||
| if found_entry_id is not None: | ||
| fribb_batch.append( | ||
| { | ||
| "provider": "imdb", | ||
| "provider_id": imdb_id, | ||
| "entry_id": found_entry_id, | ||
| } | ||
| ) | ||
| for single_imdb_id in imdb_ids: | ||
| if not single_imdb_id: | ||
| continue | ||
| fribb_batch.append( | ||
| { | ||
| "provider": "imdb", | ||
| "provider_id": str(single_imdb_id), | ||
| "entry_id": found_entry_id, | ||
| } | ||
| ) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Avoid turning one entry into many scalar IMDb IDs without updating reverse lookups.
This fan-out makes anime_ids hold multiple provider='imdb' rows for one entry_id, but get_imdb_from_kitsu() in this file still does a scalar join with LIMIT 1. For multi-season Fribb records, Kitsu → IMDb now becomes ambiguous and the stream path can pick an arbitrary season IMDb ID. Either keep a single canonical IMDb on anime_ids, or update the reverse-lookup contract to return/handle all IMDb IDs deterministically before merging this.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@comet/services/anime.py` around lines 540 - 556, The fan-out in the Fribb
import path is creating multiple scalar IMDb rows for one entry without
adjusting the reverse lookup contract. Update the logic around the Fribb batch
append in comet/services/anime.py and the get_imdb_from_kitsu() lookup so
Kitsu→IMDb remains deterministic for multi-season records: either preserve a
single canonical IMDb per entry_id in anime_ids, or make the reverse lookup
return and merge all matching IMDb IDs explicitly instead of relying on a scalar
LIMIT 1 join. Ensure the stream path no longer selects an arbitrary season IMDb
ID.
| if "/" not in torrent_title: | ||
| return False | ||
|
|
||
| for segment in torrent_title.split("/"): | ||
| segment = _BRACKET_CONTENT.sub(" ", segment).strip() |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Split only on separator slashes, not every /.
Line 44 uses split("/"), so canonical titles like Fate/stay night are broken into fragments and fed back into title_match. Since this helper now bypasses the normal title-mismatch rejection, that can wrongly accept or reject releases.
💡 Proposed fix
- if "/" not in torrent_title:
+ if " / " not in torrent_title:
return False
- for segment in torrent_title.split("/"):
+ for segment in re.split(r"\s+/\s+", torrent_title):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if "/" not in torrent_title: | |
| return False | |
| for segment in torrent_title.split("/"): | |
| segment = _BRACKET_CONTENT.sub(" ", segment).strip() | |
| if " / " not in torrent_title: | |
| return False | |
| for segment in re.split(r"\s+/\s+", torrent_title): | |
| segment = _BRACKET_CONTENT.sub(" ", segment).strip() |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@comet/services/filtering.py` around lines 41 - 45, The title parsing in
`is_releasable_torrent` is splitting on every slash, which breaks canonical
titles like `Fate/stay night` into unrelated fragments. Update the slash
handling so only separator slashes are treated as split points, and keep intact
title-like slashes from being fed into `title_match`. Use the existing
`torrent_title` processing block and `title_match` call site to adjust the
segmentation logic without reintroducing the normal title-mismatch path.
| match = _EPISODE_COUNT_PACK.search(title) | ||
| if match and parsed.episodes[0] == int(match.group(1)): | ||
| parsed.episodes = [] | ||
| parsed.complete = True |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Require the two counts to match before marking the release complete.
Line 27 only checks the first capture, so 3 of 12 / 3 из 12 will also be normalized into complete=True whenever RTN parsed episode 3. That turns partial packs into season-wide matches.
💡 Proposed fix
match = _EPISODE_COUNT_PACK.search(title)
- if match and parsed.episodes[0] == int(match.group(1)):
+ if match:
+ current = int(match.group(1))
+ total = int(match.group(2))
+ if current == total and parsed.episodes[0] == current:
- parsed.episodes = []
- parsed.complete = True
+ parsed.episodes = []
+ parsed.complete = True📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| match = _EPISODE_COUNT_PACK.search(title) | |
| if match and parsed.episodes[0] == int(match.group(1)): | |
| parsed.episodes = [] | |
| parsed.complete = True | |
| match = _EPISODE_COUNT_PACK.search(title) | |
| if match: | |
| current = int(match.group(1)) | |
| total = int(match.group(2)) | |
| if current == total and parsed.episodes[0] == current: | |
| parsed.episodes = [] | |
| parsed.complete = True |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@comet/utils/parsing.py` around lines 26 - 29, The completion check in parsing
logic is too permissive because it only compares the first captured count from
_EPISODE_COUNT_PACK against parsed.episodes[0]. Update the normalization in the
parsing function so the title’s two counts must both match the parsed episode
count before setting parsed.complete to True and clearing parsed.episodes. Use
the existing match handling around _EPISODE_COUNT_PACK and the
parsed.episodes/parsed.complete fields to keep partial packs from being marked
complete.
RTN misreads the batch count in RU/anime release names (e.g. "E13 of 13",
"13 из 13") as a single episode number, so episode-scope matching dropped
these full-season packs for every episode except that number. Detect the
count-of-total pattern and, when the parsed single episode equals the batch
count, clear the episode list and mark the release complete so it matches
any requested episode within the season.
Summary by CodeRabbit
New Features
Bug Fixes