-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
fix: improve season validation logic in torrent parsing #1011
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request refines the season validation logic within the Changes
Sequence Diagram(s)sequenceDiagram
participant S as Scraper Service
participant P as _parse_results
participant L as Logger
S->>P: Process torrent results
P->>P: Identify missing seasons via list comprehension
alt At most one missing season
P->>L: Log debug message for accepted torrent (missing season details)
P-->>S: Return accepted torrent
else More than one missing season
P->>L: Log debug message for skipped torrent (list missing seasons)
P-->>S: Return skipped torrent
end
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/program/services/scrapers/shared.py (3)
99-101
: Add type hints and improve comment clarity.The list comprehension and condition would benefit from type hints and a more detailed comment explaining the rationale.
- # Check if torrent has most of the seasons we need - missing_seasons = [season for season in needed_seasons if season not in torrent.data.seasons] - if len(missing_seasons) <= 1: # Allow at most 1 missing season because Trakt doesn't always index shows according to uploaders + # Allow at most 1 missing season to handle Trakt indexing discrepancies + # For example: If Trakt lists seasons 1-4 but uploaders consider seasons 1-3 as complete + missing_seasons: list[int] = [season for season in needed_seasons if season not in torrent.data.seasons] + if len(missing_seasons) <= 1:
99-107
: Add unit tests for the season validation logic.The changes to the season validation logic need test coverage to ensure reliability. Consider adding tests for:
- Torrent with all needed seasons
- Torrent missing one season (should be accepted)
- Torrent missing multiple seasons (should be rejected)
- Edge cases like empty season lists
Would you like me to help create these test cases? I can generate a test suite that covers these scenarios.
99-107
: Update documentation to reflect the new season validation behavior.The changes to how missing seasons are handled should be documented to help users understand when torrents will be accepted or rejected.
Would you like me to help draft documentation that explains:
- The "one missing season" rule
- Why this leniency exists (Trakt indexing discrepancies)
- How to use the debug logs to understand torrent acceptance/rejection
Pull Request Check List
Resolves: #issue-number-here
Description:
Summary by CodeRabbit