Conversation
Add support for matching torrents that use air dates (YYYY.MM.DD) instead of season/episode numbers (S##E##). This enables scraping and downloading for daily talk shows like The Daily Show, Late Night, etc. Changes: - Add _check_aired_date_match() helper in scrapers/shared.py - Update scraper to match episodes by aired_at when no episode numbers - Update downloader to match files by date for daily shows - Add daily_episode_file_template setting for date-based naming - Add aired_year, aired_month, aired_day, aired_date template variables
WalkthroughAdds date-based episode matching for daily shows across scraper, downloader, and naming. Downloader now supports per-service initialization and cooldown tracking. Naming gains aired_year/month/day/date fields and a daily_episode_file_template setting with validation. Changes
Sequence Diagram(s)sequenceDiagram
participant RTN as RTN Parser
participant Scraper as Scraper Service
participant Matcher as Date Matcher
participant DB as Metadata DB
participant Downloader as Downloader Service
participant FS as FileSystem / Naming
RTN->>Scraper: Parse torrent -> returns date (no S/E)
Scraper->>Matcher: _check_aired_date_match(torrent_date)
Matcher->>DB: query episodes by aired_at
DB-->>Matcher: episode metadata (aired_at)
Matcher-->>Scraper: match result (episode id)
Scraper-->>Downloader: enqueue matching result
Downloader->>Downloader: initialize services & cooldowns
Downloader->>Matcher: match_file_to_item(file, item) with torrent date
Matcher-->>Downloader: matched episode id
Downloader->>Downloader: mark episode processed (processed_episode_ids)
Downloader->>FS: request filename for item
FS->>FS: use daily_episode_file_template with aired_date fields
FS-->>Downloader: rendered filename
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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: 1
🤖 Fix all issues with AI agents
In `@src/program/services/downloaders/__init__.py`:
- Around line 375-382: The compound boolean expression in the conditional that
checks instances of Show, Season, Episode is ambiguous due to mixed and/or
precedence; update the condition around file_data checks in the if block that
references file_data.episodes, file_data.date, file_data.seasons (the block
starting with "if isinstance(item, (Show, Season, Episode))") by adding explicit
parentheses to group the intended logic — i.e., clearly parenthesize the "no
episodes and no date" check as one unit, the "episodes contains only 0" check as
another, and the "seasons first element equals 0" check — so the final
expression uses parentheses to enforce the intended precedence and avoid
mis-evaluation.
🧹 Nitpick comments (3)
src/program/services/downloaders/__init__.py (2)
358-359: Consider logging the exception for debugging.The blind
except Exceptionswallows all errors silently. While this may be intentional to prevent crashes, logging the exception at debug level would help diagnose issues.♻️ Suggested improvement
- except Exception: + except Exception as e: + logger.debug(f"Failed to calculate episode_cap: {e}") pass
372-373: Consider logging parse failures for debugging.Silently continuing on parse errors makes debugging difficult. A trace-level log would help identify problematic filenames.
♻️ Suggested improvement
- except Exception: + except Exception as e: + logger.trace(f"Failed to parse filename '{file.filename}': {e}") continuesrc/program/settings/models.py (1)
446-490: Consider extracting shared test data and improving exception chaining.
The
test_datadict is duplicated betweenvalidate_naming_templateandvalidate_daily_episode_template. Consider extracting to a module-level constant.Per static analysis (B904), use
raise ... from efor proper exception chaining.♻️ Suggested improvement for exception chaining
formatter.format(v, **test_data) return v except Exception as e: - raise ValueError(f"Invalid daily episode naming template syntax: {e}") + raise ValueError(f"Invalid daily episode naming template syntax: {e}") from e♻️ Optional: Extract shared test data
# At module level or as a class constant _TEMPLATE_TEST_DATA = { "title": "Test Title", "year": 2024, "season": 1, "episode": 1, "show": { "title": "Test Show", "year": 2024, "tvdb_id": "12345", "imdb_id": "tt1234567", }, "season_obj": {"number": 1, "title": "Season 1"}, "tmdb_id": "12345", "tvdb_id": "12345", "imdb_id": "tt1234567", "aired_year": 2024, "aired_month": 1, "aired_day": 15, "aired_date": "2024-01-15", # ... rest of fields }
Add explicit parentheses to group conditions checking file_data.episodes, file_data.date, and file_data.seasons to avoid ambiguous and/or evaluation.
Pull Request Check List
Resolves: #1350
Description:
Add support for matching torrents that use air dates (YYYY.MM.DD) instead
of season/episode numbers (S##E##). This enables scraping and downloading
for daily talk shows like The Daily Show, Late Night, etc.
Changes:
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.