Implement episode discovery #6

Merged
coding-agent-marvin8 merged 0 commits from refs/pull/6/head into main 2026-06-17 06:20:41 +00:00
coding-agent-marvin8 commented 2026-06-17 04:30:08 +00:00 (Migrated from codeberg.org)

Closes #5

Adds src/sub2pod/discovery.py with:

  • Episode dataclass (audio_path, date, title, info: EpisodeInfo | None)
  • discover_episodes(channel_dir): globs for .opus/.mp3/.m4a, pairs .nfo sidecars, sorts newest-first

Tests cover: empty dir, non-matching filenames skipped, each extension with and without sidecar, sort order, and real NAS data (skipped in CI).

Closes #5 Adds `src/sub2pod/discovery.py` with: - `Episode` dataclass (`audio_path`, `date`, `title`, `info: EpisodeInfo | None`) - `discover_episodes(channel_dir)`: globs for `.opus`/`.mp3`/`.m4a`, pairs `.nfo` sidecars, sorts newest-first Tests cover: empty dir, non-matching filenames skipped, each extension with and without sidecar, sort order, and real NAS data (skipped in CI).
coding-agent-marvin8 commented 2026-06-17 06:09:34 +00:00 (Migrated from codeberg.org)

src/sub2pod/discovery.py line 30

No exception handling for parse_episode_nfo. If the NFO file is malformed or unreadable…

Fixed in commits 3af81ee and 2c6f672. A try/except Exception now wraps the parse_episode_nfo call; any parse failure (malformed XML, unreadable file, etc.) silently sets info=None so discovery of other episodes continues uninterrupted. A new test (returns Episode with info=None when .nfo sidecar contains malformed XML) was added to cover this case.

[`src/sub2pod/discovery.py` line 30](https://codeberg.org/marvin8/sub2pod/pulls/6#issuecomment-17604314) > No exception handling for `parse_episode_nfo`. If the NFO file is malformed or unreadable… ✅ Fixed in commits `3af81ee` and `2c6f672`. A `try/except Exception` now wraps the `parse_episode_nfo` call; any parse failure (malformed XML, unreadable file, etc.) silently sets `info=None` so discovery of other episodes continues uninterrupted. A new test (`returns Episode with info=None when .nfo sidecar contains malformed XML`) was added to cover this case.
coding-agent-marvin8 commented 2026-06-17 06:09:41 +00:00 (Migrated from codeberg.org)

src/sub2pod/discovery.py line 24

The glob pattern matches audio files by extension, but if the same episode exists in multiple formats (e.g., .opus and

🔴 Not actioned. ytdl-sub produces a single audio format per episode, so duplicate stems are not expected in practice. If an episode does exist in two formats, treating them as independent Episode objects is the correct behaviour — Phase 4 (RSS generation) will emit a separate <enclosure> for each, letting clients pick the format they support. Deduplicating here would require choosing a preferred format, which is a Phase 4 concern. A new test (discovers multiple audio formats for the same stem as separate episodes) documents this intentional behaviour.

[`src/sub2pod/discovery.py` line 24](https://codeberg.org/marvin8/sub2pod/pulls/6#issuecomment-17604317) > The glob pattern matches audio files by extension, but if the same episode exists in multiple formats (e.g., `.opus` and 🔴 Not actioned. ytdl-sub produces a single audio format per episode, so duplicate stems are not expected in practice. If an episode does exist in two formats, treating them as independent `Episode` objects is the correct behaviour — Phase 4 (RSS generation) will emit a separate `<enclosure>` for each, letting clients pick the format they support. Deduplicating here would require choosing a preferred format, which is a Phase 4 concern. A new test (`discovers multiple audio formats for the same stem as separate episodes`) documents this intentional behaviour.
coding-agent-marvin8 commented 2026-06-17 06:09:48 +00:00 (Migrated from codeberg.org)

tests/test_discovery.py line 1

Missing test case: a malformed .nfo file (e.g., invalid XML or missing required fields) should not crash `discover_epi

Added in commit 3af81ee: returns Episode with info=None when .nfo sidecar contains malformed XML. It creates an audio file with a corrupt NFO sidecar and asserts that discover_episodes returns the episode with info=None rather than raising. The corresponding implementation fix landed in 2c6f672.

[`tests/test_discovery.py` line 1](https://codeberg.org/marvin8/sub2pod/pulls/6#issuecomment-17604320) > Missing test case: a malformed `.nfo` file (e.g., invalid XML or missing required fields) should not crash `discover_epi ✅ Added in commit `3af81ee`: `returns Episode with info=None when .nfo sidecar contains malformed XML`. It creates an audio file with a corrupt NFO sidecar and asserts that `discover_episodes` returns the episode with `info=None` rather than raising. The corresponding implementation fix landed in `2c6f672`.
coding-agent-marvin8 commented 2026-06-17 06:09:54 +00:00 (Migrated from codeberg.org)

tests/test_discovery.py line 1

Missing test case: duplicate audio files (same stem but different extensions) are currently not tested…

Added in commit 3af81ee: discovers multiple audio formats for the same stem as separate episodes. The test confirms that both .opus and .mp3 files for the same stem are independently discovered. Deduplication is intentionally not implemented — see the reply to the related MEDIUM comment for the rationale.

[`tests/test_discovery.py` line 1](https://codeberg.org/marvin8/sub2pod/pulls/6#issuecomment-17604323) > Missing test case: duplicate audio files (same stem but different extensions) are currently not tested… ✅ Added in commit `3af81ee`: `discovers multiple audio formats for the same stem as separate episodes`. The test confirms that both `.opus` and `.mp3` files for the same stem are independently discovered. Deduplication is intentionally not implemented — see the reply to the related MEDIUM comment for the rationale.
coding-agent-marvin8 commented 2026-06-17 06:10:01 +00:00 (Migrated from codeberg.org)

ROADMAP.md line 10

Inconsistent capitalization of completion marker. Other lines use lowercase 'x' inside brackets ('[x]'), but this line u

Fixed in commit a6ae848[X] changed to [x] for consistency.

[`ROADMAP.md` line 10](https://codeberg.org/marvin8/sub2pod/pulls/6#issuecomment-17604326) > Inconsistent capitalization of completion marker. Other lines use lowercase 'x' inside brackets ('[x]'), but this line u ✅ Fixed in commit `a6ae848` — `[X]` changed to `[x]` for consistency.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
marvin8/sub2pod!6
No description provided.