Repository navigation
fix(catalog): list and play every episode of a multi-episode file - #3112
Conversation
A file named S01E01-E02 links to its first episode only, so only that episode got a library membership and the episode lists hid the second one, while season availability already counted it as present. Each episode a present multi-episode file spans now gets the folder membership a linked file gives, and loses it with the file. File lookups by episode (detail, playback, overlays, durations, Jellyfin file presence) resolve a spanned episode to the same file. Completing the file marks the rest of its range watched, so Next Up does not offer the same file again. Refs Silo-Server#739 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HPRMUf61FKDxra1ZSpK4iK
…okups Spanned episodes now lose their membership when a scoped scan, a relink, a content-link clear or a file split checks the file's first episode, not only on a full folder reconcile. Lookups search at most ten earlier episodes, the bound watch history import already uses, so long seasons do not join every earlier episode. A season download fetches a multi-episode file once. Probed durations stay on the first episode, so a later one keeps its own runtime. Jellyfin episode targets report a spanned episode as having a file. Refs Silo-Server#739 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HPRMUf61FKDxra1ZSpK4iK
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Episode coverage and catalog rules internal/catalog/multi_episode_files.go, migrations/sql/20261028165553_episode_catalog_spanned_files.sql, migrations/sql/20261028165234_reparse_multi_episode_ranges.sql |
Shared SQL rules identify files serving an episode and expand ranges up to the configured limit. Catalog refreshes include covered episodes. The separate reparse migration clears increasing ranges for non-import editions. |
Episode file discovery and selection internal/scanner/file_repo.go, internal/catalog/episode_repo.go, internal/jellycompat/batch_loaders.go, internal/catalog/overlay_summaries.go, internal/catalog/playable_targets.go, internal/catalog/playable_targets_postgres.go, internal/catalog/playable_targets_plan_db_test.go, internal/sections/overlay_summaries_test.go, internal/downloads/service.go, internal/api/handlers/items.go |
Episode file lookups, playable-target checks, overlay summaries, and download resolution include files that span episodes. Episode duration lookup filters files by episode ID. |
Episode membership lifecycle internal/catalog/episode_library_repo.go, internal/catalog/filesplit/filesplit.go, internal/scanner/file_repo.go, internal/scanner/scanner.go, internal/scanner/multi_episode_file_test.go, scripts/ci/db-contracts.txt |
Reconciliation, file linking, series moves, and scanner synchronization create or remove memberships based on file coverage. The database-backed test checks lookups, membership restoration, and stale membership removal. |
Playback history for covered episodes internal/watchstate/service.go, internal/api/handlers/playback.go, internal/api/handlers/playback_test.go |
After a qualifying stop, later episodes covered by the file are recorded as watched. The test checks which episodes are complete after a near-end stop. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix
Possibly related issues
- Silo-Server/silo-server#2116 — The changes associate a multi-episode file with later episodes in its range; per-series episode-order selection remains outside this change.
Sequence Diagram(s)
sequenceDiagram
participant Scanner
participant Catalog as catalog.InsertSpannedEpisodeMemberships
participant Database
Scanner->>Catalog: Insert memberships for files in the current folder and scope
Catalog->>Database: Insert missing episode-folder memberships
Database-->>Catalog: Return inserted series IDs
Catalog-->>Scanner: Return series IDs
Scanner->>Database: Recompute membership denormalizations
Suggested reviewers: quick104, rhainland
Merge Risk: 
Minimal · up to 3a879
-
Files named for episode ranges now list, play and mark watched across their covered episodes, bounded to the first eleven episodes. After upgrade, existing libraries need a library scan to restore real multi-episode ranges. No unresolved merge-blocking defect was identified in the supplied evidence.
Security architecture risk: 
Low · up to 3a879
-
The change is bounded to episodes sharing an existing media file. The reviewed playback and library access controls remain in place, and no introduced access-control bypass was established. Download authorization and some interrupted-update behavior remain incompletely verified.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The added serving relationship extends one file's effects to later episodes within its existing season rather than granting authority over arbitrary series. Playback watch-state effects are directed to the session's user and profile.
Security Findings and Attack Paths
- observed — Download selection prefers access-filtered candidates but returns the original candidates when none survive filtering. The changed creation path checks parent-item accessibility. Delivery reauthorization and whether spanning lookup materially changes this fallback's exposure were not resolved, so an introduced download bypass is not established.
Trust Boundaries and Controls
- observed — Both playable-target query paths pass the same file conditions into the new spanning branch, including library scope, enabled-folder checks and playback-quality limits. Episode-list responses filter expanded repository results before exposing file metadata.
- observed — Native playback loads the requested file through a gate that checks its parent item and file-level library and quality permissions. The stop endpoint checks both account and profile ownership before invoking the transition that can write additional episode history.
Resilience and Maintainability Implications
- observed — For PostgreSQL, later-episode progress and history are committed in one transaction. The progress upsert checks completed state atomically, and history is written only for targets actually marked. First-episode history is a separate operation; a later-range failure is logged, and qualifying repeated stops can attempt the range again. This does not establish durable recovery after every interruption.
- observed — Reviewed reconciliation, relink, clear and file-move paths pair file ownership changes with spanning-membership maintenance inside transactions. Membership insertion uses conflict-safe writes and ordered series locking. Scoped scanner repair can still leave temporary stale membership between successive transactions until reconciliation runs.
-
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
Issue [
#739] requires support for episode ranges and association of both episodes with one physical file. The PR uses the existing first-episode link and adds span-aware SQL withMaxEpisodeSpan = 10. It maintains later-episode library memberships during scan, reconcile, relink, bulk link, and file split operations. Episode, playback, Jellyfin, overlay, catalog, and download paths resolve the serving file. Playback records later episodes as watched when the file completes. The database and playback tests cover the main range behavior.
Full details: Out of Scope Changes check
-
Explanation
The changes remain within issue [
#739]. The shared SQL, membership maintenance, lookup changes, catalog refresh, download de-duplication, watch-state propagation, migrations, and tests directly support multi-episode file behavior. No unrelated product change is demonstrated.
-
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
The Evidence table is empty, so reviewers cannot see the visible changes described in the text.
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
bca84a7e-21c2-4514-9a61-9b477cdc055b
Files selected for processing: 13-
internal/api/handlers/playback.gointernal/api/handlers/playback_test.gointernal/catalog/episode_library_repo.gointernal/catalog/episode_repo.gointernal/catalog/filesplit/filesplit.gointernal/catalog/multi_episode_files.gointernal/downloads/service.gointernal/jellycompat/batch_loaders.gointernal/scanner/file_repo.gointernal/scanner/multi_episode_file_test.gointernal/scanner/scanner.gointernal/watchstate/service.goscripts/ci/db-contracts.txt
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
-
…range Adding spanned memberships now locks the candidate series rows in content ID order before inserting, matching the parent-first order that curated rebind and split take. Completing a multi-episode file marks watched only the episodes the file serves, up to MaxEpisodeSpan past its first, so it agrees with the lookups. Refs Silo-Server#739 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
The Evidence section now shows the episode list before and after on desktop and mobile, but these visible changes still lack matching evidence:
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
Quick104
left a comment
There was a problem hiding this comment.
Review of a6ab3e6, with findings from my pass and a cross-provider pass (Codex gpt-6.1-sol), each checked against the source. Main merges cleanly into this branch and the changed packages build.
Both new tests fail on the base and pass at this head. I ran the database contract against a migrated PostgreSQL. The failing Go DB pins check is TestLogPartitionsMatchPartmanOnNonUTCServer, which this PR doesn't touch.
The first finding matters most: on existing installs, stale stored ranges make this PR show the wrong files and mark the wrong episodes watched. The rest are paths that still read only media_files.episode_id. I'm fixing all of them on this branch and will post a summary when the fixes are pushed.
Review by Claude Code (claude-opus-5-5) for a maintainer.
…ranges Parsers before Silo-Server#1313 stored multi-episode ranges for names that are not multi-episode files, such as "S02E01 - 013 - Title" (episodes 1-13). With spanned episodes now served by the file, those rows listed one file as a version of up to ten later episodes and marked them watched on completion. A migration clears the stored ranges so the next scan writes them again with the current parser. Later episodes of a multi-episode file now also get a play target on cards, poster badges, and catalog entries with the file's technical fields, so filters match them. A native download of a later episode resolves to the file, keyed on its first episode like a season download, which also dedupes it across pages. A file split moves the spanned episodes' watch state. Folder reconcile locks the series it adds and removes memberships for in one ordered statement. A repeated stop of a completed play marks the range again, so a failed mark is not lost. Marking a later episode watched records its own runtime, not the file's. Refs Silo-Server#739 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Maintainer review summaryReviewed head: AddressedAll nine findings from the review are fixed in
Verification
Left for maintainers
Other checks
Fit: 8/10 · Readiness: 7/10 — conditional (assuming CI is green) Fit: issue #739 is a real gap in Series libraries, and the approach reuses the range relation season availability already had. It stretches simplicity: the span rule now has a Go copy and a SQL copy, and several read paths depend on it. Readiness: every verified defect is fixed, and the main paths have tests that fail without the fixes. The condition is the paths listed under Verification that have no test yet. Review by Claude Code (claude-opus-5-5) for a maintainer. |
|
The PR's Suggested replacement: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Requested by Tobechukwu Njoku
Problem
Closes #739
Related issue: N/A
Validation tasks: none
A file named for several episodes, such as
Show - S01E01-E02 - Title.mkv, shows only its first episode. The filename parses correctly (episodes 1 to 2), but the file links to episode 1 only, so only episode 1 gets a library membership. Every episode list leaves out episode 2, in the web app and in Jellyfin clients, while season availability counts it as present. This change lists every episode the file spans, plays the file from each one, and marks the whole range watched when the file finishes.Approach
The file keeps its single link to its first episode (
media_files.episode_id), so nothing that reads the file side changes. A multi-episode file now serves the later episodes of its range:episode_libraries). It is added where links are made (scan repair, folder reconcile, relink, bulk link, file split) and removed with the file. A scoped scan, relink or link clear that checks the first episode also checks the episodes after it.The shared SQL lives in
internal/catalog/multi_episode_files.go. Season availability already counted spanned episodes and is unchanged. Next Up still offers only episodes with a file linked directly, so it never offers the same file again for its later episodes.Validation
internal/api/handlersfailsTestPersonalPosterSourceRefusesLocalAddressesonly in a container without IPv6; it passes on the Linux VM.scripts/ci/db-contracts.txt) against a migrated PostgreSQL 18 database: passes, and fails on the base commit.make test-db-contracts: all pins pass.internal/jellycompatTestPlaybackInfoWithoutStripOrToneMapStillHasNoRouteandTestPlaybackInfoSkipsStripWhenRPUCannotBeStrippedfail the same way on the base commit (8b84639) without this change.Evidence
Surface and build: web app series page, Episodes section, desktop (1440 px) and phone (390 px) widths, plus the second episode's detail page. Test library with one generated
Hey Arnold! - S01E01-E02 - Downtown as Fruits + Eugene's Bike.mkv, base 8b84639 vs this branch. Before: "1 total", only Episode 1. After: "2 total", Episode 2 listed with the file's badges and a Play button.Risks
Two migrations. One clears stored multi-episode ranges, except ones an import supplied, because parsers before #1313 stored ranges for names such as
S02E01 - 013 - Title(episodes 1–13), and this change would make those files serve later episodes. The next library scan writes real ranges again with the current parser; until then a multi-episode file shows only its first episode, as before. The other builds each episode's catalog entry (the technical filters) from the files serving it. Existing libraries pick up the new memberships on their next scan. Known limits:Checklist
AI Disclosure
/code-review, high effort) read the full diff for correctness. It found ten issues, including stale memberships after scoped scans and relinks, duplicate season downloads, doubled runtimes on spanned episodes, and an unbounded self-join on long seasons. Seven were fixed in the second commit. Three were accepted as limits and are described above: progress stays on the first episode, rewatch counts, and marker edits.Note
Fix catalog to list and play every episode served by a multi-episode file
ServedEpisodeFilesSQL,NoServingEpisodeFileSQL,EpisodeHasServingFileSQL,SpanReachSQL,InsertSpannedEpisodeMemberships) with aMaxEpisodeSpanbound of 10 episodes. Repositories for catalog lookups, overlay summaries, playable targets, and file listings now treat an episode as served when a multi-episode file spans it, not only when a file links directlymedia_filescatalog-refresh trigger so changingmulti_episode_start/multi_episode_endrefreshes catalog entries for episodes covered by the old and new ranges;refresh_episode_catalog_entrycomputes technical stats through the newepisode_serving_filesSQL functionPlaybackHandler.markSpannedEpisodeWatchedandwatchstate.Service.RecordSpannedEpisodeWatched; downloads deduplicate a selected multi-episode file to one item keyed to its linked episodemulti_episode_startandmulti_episode_endto NULL for non-import rows where end <= start; the Down migration is a no-op and does not restore them. Span lookups are capped at 10 episodes past a file's first episode, so wider ranges are truncatedMacroscope summarized 3a879ca.