Skip to content

feat: track episode availability from sonarr - #3355

Open
0xSysR3ll wants to merge 2 commits into
feat-episode-availabilityfrom
feat-episode-availability-scanners
Open

0xSysR3ll wants to merge 2 commits into
feat-episode-availabilityfrom
feat-episode-availability-scanners

Conversation

@0xSysR3ll

@0xSysR3ll 0xSysR3ll commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

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)

@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

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 08926170-549f-48cc-9a83-254b5cfbd717

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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
Contributor 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 Outdated
Comment thread server/lib/availabilitySync.ts Outdated
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 Outdated
@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.

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