Skip to content

feat: track episode availability from sonarr - #3355

Merged
0xSysR3ll merged 3 commits into
feat-episode-availabilityfrom
feat-episode-availability-scanners
Sep 18, 2026
Merged

0xSysR3ll merged 3 commits into
feat-episode-availabilityfrom
feat-episode-availability-scanners

Conversation

@0xSysR3ll

@0xSysR3ll 0xSysR3ll commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Description

Part 2 of #1671 to make the review easier.
Implements episode availability in Sonarr's scanner.

How Has This Been Tested?

Same tests as part 1 + server checks.

Screenshots / Logs (if applicable)

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Summary by CodeRabbit

  • New Features

    • Added optional episode-level availability tracking for Sonarr TV shows.
    • Episode file status is synchronized, including support for 4K availability.
    • Anime-specific metadata provider selection is supported during synchronization.
  • Bug Fixes

    • Removed episodes no longer available are excluded from season availability results.
    • Synchronization continues when episode lookups or metadata requests fail.

@0xSysR3ll
0xSysR3ll requested a review from a team as a code owner August 8, 2026 21:38
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 10fbf24a-8604-4e5d-b02a-7f404701b827

📥 Commits

Reviewing files that changed from the base of the PR and between 34762ab and 5578a5e.

📒 Files selected for processing (6)
  • server/lib/availabilitySync.test.ts
  • server/lib/availabilitySync.ts
  • server/lib/scanners/baseScanner.ts
  • server/lib/scanners/sonarr/index.ts
  • server/lib/scanners/sonarr/sonarr.test.ts
  • server/routes/tv.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fallenbagel

Copy link
Copy Markdown
Member

Is the media server scanner gonna be stacked on this PR?

@0xSysR3ll

0xSysR3ll commented Aug 9, 2026 •

Copy link
Copy Markdown
Member Author

Is the media server scanner gonna be stacked on this PR?

It's supposed to but I guess I missed a step somewhere.

@0xSysR3ll
0xSysR3ll force-pushed the feat-episode-availability-scanners branch from b2315e6 to 105baae Compare August 10, 2026 16:26
@github-actions github-actions Bot added the merge conflict Cannot merge due to merge conflicts label Aug 15, 2026
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@0xSysR3ll
0xSysR3ll force-pushed the feat-episode-availability-scanners branch from 105baae to 7e1e85c Compare August 15, 2026 14:06
@github-actions github-actions Bot removed the merge conflict Cannot merge due to merge conflicts label Aug 15, 2026
@0xSysR3ll
0xSysR3ll force-pushed the feat-episode-availability-scanners branch from 7e1e85c to c355d99 Compare August 15, 2026 14:39
@0xSysR3ll 0xSysR3ll changed the title feat: wire episode availability to Sonarr scanner feat: track episode availability from sonarr Aug 18, 2026
@0xSysR3ll
0xSysR3ll marked this pull request as draft August 18, 2026 17:15
@0xSysR3ll
0xSysR3ll force-pushed the feat-episode-availability-scanners branch 2 times, most recently from e1d4158 to 3937280 Compare August 18, 2026 19:56
@github-actions github-actions Bot added the merge conflict Cannot merge due to merge conflicts label Aug 31, 2026
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@0xSysR3ll
0xSysR3ll force-pushed the feat-episode-availability-scanners branch from 3937280 to 2a65ca9 Compare August 31, 2026 17:02
@github-actions github-actions Bot removed the merge conflict Cannot merge due to merge conflicts label Aug 31, 2026
@0xSysR3ll
0xSysR3ll force-pushed the feat-episode-availability-scanners branch from 2a65ca9 to ab54e8f Compare August 31, 2026 17:16
@0xSysR3ll
0xSysR3ll marked this pull request as ready for review August 31, 2026 17:21
Comment thread server/lib/availabilitySync.ts Resolved
Comment thread server/lib/availabilitySync.ts Resolved
Comment on lines +992 to +1010
if (shouldTrackEpisodes && hasEpisodeCache) {
const existingEpisodes = dbEpisodesBySeasonId.get(season.id) ?? [];
const toSave: Episode[] = [];

for (const existingEpisode of existingEpisodes) {
const hasFile = episodeHasFileByNumber.get(
existingEpisode.episodeNumber
);
const currentStatus = existingEpisode[is4k ? 'status4k' : 'status'];

if (
hasFile !== true &&
currentStatus !== MediaStatus.DELETED &&
currentStatus !== MediaStatus.UNKNOWN
) {
existingEpisode[is4k ? 'status4k' : 'status'] = MediaStatus.DELETED;
toSave.push(existingEpisode);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rows for numbers Sonarr no longer returns get marked DELETED but stay in the table, and the season route's guard counts every tracked row regardless of status:

seerr/server/routes/tv.ts

Lines 115 to 130 in 9062976

if (trackedEpisodes.length > 0 && metadataEpisodeNumbers.size > 0) {
const hasEpisodeNumberMismatch = trackedEpisodes.some(
(episode) => !metadataEpisodeNumbers.has(episode.episodeNumber)
);
if (hasEpisodeNumberMismatch) {
logger.debug(
'Skipping episode availability due to episode number mismatch',
{
label: 'API',
tvId: req.params.id,
seasonNumber: req.params.seasonNumber,
metadataEpisodeCount: metadataEpisodeNumbers.size,
trackedEpisodeCount: trackedEpisodes.length,
}
);

So one renumbered episode kills badges for that whole season permanently, with only a debug line to explain it. Delete the rows whose numbers are gone instead of soft-removing them, or maybe filter DELETED out of the guard.

Comment thread server/lib/scanners/baseScanner.ts Resolved
@0xSysR3ll
0xSysR3ll force-pushed the feat-episode-availability-scanners branch 2 times, most recently from d7c374a to 93eab24 Compare September 2, 2026 18:46
@github-actions github-actions Bot added the merge conflict Cannot merge due to merge conflicts label Sep 15, 2026
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@0xSysR3ll
0xSysR3ll force-pushed the feat-episode-availability-scanners branch from 93eab24 to 5578a5e Compare September 18, 2026 21:46
Comment thread server/lib/availabilitySync.ts Fixed
Comment thread server/lib/availabilitySync.ts Fixed
@0xSysR3ll
0xSysR3ll merged commit 0ffd199 into develop Sep 18, 2026
4 checks passed
@0xSysR3ll
0xSysR3ll deleted the feat-episode-availability-scanners branch September 18, 2026 21:54
@0xSysR3ll
0xSysR3ll restored the feat-episode-availability-scanners branch September 18, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Cannot merge due to merge conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants