Skip to content

Fix missing pagination in episode fetching for series with >500 episodes#237

Open
skilaky wants to merge 1 commit into
jellyfin:masterfrom
skilaky:fix/episode-pagination
Open

Fix missing pagination in episode fetching for series with >500 episodes#237
skilaky wants to merge 1 commit into
jellyfin:masterfrom
skilaky:fix/episode-pagination

Conversation

@skilaky
Copy link
Copy Markdown

@skilaky skilaky commented Feb 18, 2026

Summary

  • GetSeriesEpisodesAsync() and GetEpisodeTvdbId() in TvdbClientManager.cs only fetched page 0 (first 500 episodes) from the TVDB v4 API
  • For series with more than 500 episodes in a given season type (e.g. DVD order), episodes beyond page 0 were invisible to the plugin
  • This caused incorrect season/episode assignments for long-running series

Root Cause

The TVDB v4 API returns a maximum of 500 episodes per page. Both methods had page: 0 hardcoded with no pagination loop. The same codebase already has working pagination in GetUpdates(), but it was never applied to episode fetching.

Example: Tatort (TVDB ID: 83214)

Tatort has 1,340 episodes in DVD order, spread across 3 API pages:

API Page DVD Seasons Episodes
Page 0 S1 – S51 500
Page 1 S52 – S72 500
Page 2 S72 – S96 340

Before fix: Episodes from seasons 52+ (pages 1-2) were invisible → 95% of episodes had wrong season/episode metadata.

After fix: All pages are fetched, all seasons are correctly mapped.

Changes

  1. GetSeriesEpisodesAsync(): Added pagination loop to aggregate episodes from all pages into a single Data2 result (matching the existing GetUpdates() pattern)
  2. GetEpisodeTvdbId(): Added pagination loop to iterate through pages until the requested episode is found

Affected Series

Any series with >500 episodes in a season type ordering, including:

  • Tatort (1,340+ episodes in DVD order)
  • The Simpsons (700+ episodes)
  • Doctor Who (800+ episodes)
  • And many other long-running series

Test Plan

  • Verify Tatort (83214) in DVD order correctly maps episodes from seasons 52+ (previously broken)
  • Verify series with <500 episodes still work correctly (no regression)
  • Verify MissingEpisodeProvider creates correct virtual seasons for all pages
  • Verify caching still works correctly with aggregated episode data

GetSeriesEpisodesAsync and GetEpisodeTvdbId only fetched page 0 (first
500 episodes) from the TVDB v4 API. For long-running series like Tatort
(1340 episodes in DVD order), episodes beyond page 0 were invisible to
the plugin, causing incorrect season/episode assignments.

This adds pagination loops (matching the existing pattern in GetUpdates)
to both methods so all episodes are fetched across all pages.

Fixes incorrect metadata for any series with more than 500 episodes in
a given season type ordering.
@skilaky skilaky force-pushed the fix/episode-pagination branch from e27ea28 to 013eb0b Compare February 18, 2026 08:26
return seriesResult.Data;

// Each page has a limit of 500 episodes. Fetch all remaining pages.
var allEpisodes = new List<EpisodeBaseRecord>(seriesResult.Data?.Episodes ?? Array.Empty<EpisodeBaseRecord>());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
var allEpisodes = new List<EpisodeBaseRecord>(seriesResult.Data?.Episodes ?? Array.Empty<EpisodeBaseRecord>());
var allEpisodes = new List<EpisodeBaseRecord>(seriesResult.Data?.Episodes ?? []);

Same for other places

@iampegram
Copy link
Copy Markdown

I think some of my code from #242 should be added into this, because the endpoint used in both places has a long-standing flaw where season-types 'altdvd' and 'alttwo' return no episodes even when there are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants