Skip to content

Work around TVDB API bug for altdvd / alttwo season types (fixes #226)#246

Open
superuser404notfound wants to merge 1 commit into
jellyfin:masterfrom
superuser404notfound:upstream-altdvd-workaround
Open

Work around TVDB API bug for altdvd / alttwo season types (fixes #226)#246
superuser404notfound wants to merge 1 commit into
jellyfin:masterfrom
superuser404notfound:upstream-altdvd-workaround

Conversation

@superuser404notfound
Copy link
Copy Markdown

Summary

Resolves #226 by working around thetvdb/v4-api#340 where the TVDB v4 API returns an empty episodes array for the altdvd and alttwo season types, even though the corresponding season records exist and the public TVDB web UI shows them correctly. The upstream API bug has been open since late 2023 with no movement, so handling it client-side seems to be the only path forward.

Approach

This builds on the per-season fallback approach proposed by @iampegram in #242. When the primary GetSeriesEpisodesAsync call comes back empty, walk the extended series record, filter Seasons by SeasonType.Type, and aggregate each matching season's Episodes via the existing IExtendedSeasonClient (GetSeasonByIdAsync). No new DI wiring is needed.

The same workaround is also applied at the GetEpisodeTvdbId entry point. The SDK's filter-by-SxE variant of the bulk endpoint is broken for the same season types, so TvdbEpisodeProvider.GetEpisode was falling through to the "Episode SxxExx not found" log path even when the per-season data would have resolved correctly. Routing altdvd / alttwo through the workaround-aware bulk fetch and matching locally fixes the per-episode resolution.

The per-episode seasonNumber / number fields returned by /seasons/{id}/extended are already populated in the alternate-order numbering (matching what the Alternate DVD Order tab shows on thetvdb.com for the queried season type), so SxE matching on the aggregated list is straightforward.

Verification

End-to-end on a real Jellyfin 10.11.x install against series 75886 (SpongeBob SquarePants), with the Alternate DVD Order display setting:

Library file Resolved tvdb id Title
altdvd-S2E1 9289284 Your Shoe's Untied / Squid's Day Off
altdvd-S2E8 1065131 The SpongeBob Christmas Special
altdvd-S2E11 9289295 Mermaid Man and Barnacle Boy III / Squirrel Jokes
altdvd-S2E19 9289303 Jellyfish Hunter / The Fry Cook Games

All matches were cross-verified against the Alternate DVD Order tab at https://thetvdb.com/series/spongebob-squarepants .

Why a new PR rather than continuing #242

#242 has been open since March without review and contains compile-time errors that prevented it from being mergeable (s.Type = seasonType assignment instead of comparison; _serviceProvider.GetRequiredService<ISeasonsClient>() against a type that isn't registered with the DI container, which would also throw at runtime even after the comparison was fixed). I tried to keep this PR a clean re-implementation rather than force-pushing over @iampegram's branch, so credit and discussion history are preserved.

Credits

Thanks to everyone who triaged this issue:

Test plan

  • dotnet build passes with TreatWarningsAsErrors and the existing StyleCop / nullability analyzers.
  • Pre-existing aired / dvd / absolute display-order paths are unchanged (the workaround only fires when the primary endpoint returns empty).
  • Verified against the live TVDB v4 API for series 75886, all altdvd-S2 episode positions resolve to the expected tvdb ids.
  • Verified end-to-end in Jellyfin 10.11.x: titles, overviews and images for altdvd-ordered episodes now match the Alternate DVD Order tab on thetvdb.com .

…in#226)

The TVDB v4 API returns an empty episodes array for the altdvd and
alttwo season types via the /series/{id}/episodes/{seasonType} endpoint
(both the unfiltered bulk variant and the filter-by-SxE variant), even
though the corresponding season records exist and the public TVDB web
UI displays the episodes correctly. The upstream API bug is tracked at
thetvdb/v4-api#340 and has been open since late 2023 without movement.

When the primary endpoint returns nothing, the workaround walks the
extended series record, filters its Seasons list by the requested
SeasonType.Type slug and aggregates each matching season's episodes via
the existing IExtendedSeasonClient + memory cache. The per-episode
seasonNumber / number fields returned by /seasons/{id}/extended are
already populated with the alternate-order numbering (verified against
the live API and the public web UI for SpongeBob SquarePants altdvd
ordering), so downstream SxE matching is straightforward and accurate.

The same workaround is also applied at the GetEpisodeTvdbId entry
point, because the filter-by-SxE variant of the SDK call is broken for
the same season types: routing altdvd / alttwo through the workaround-
aware bulk fetch and resolving the match locally yields the correct
episode id where the direct SDK call would otherwise return null.

Approach originated by iampegram in jellyfin#242. This patch is a clean, tested
implementation that reuses the plugin's existing IExtendedSeasonClient
registration (no new DI wiring required), passes nullability/StyleCop
analyzers, and has been verified end-to-end against series 75886
(SpongeBob SquarePants) on a real Jellyfin 10.11.x install:

- altdvd-S2E1 -> tvdb id 9289284 ("Your Shoe's Untied / Squid's Day Off")
- altdvd-S2E8 -> tvdb id 1065131 ("The SpongeBob Christmas Special")
- altdvd-S2E11 -> tvdb id 9289295 ("Mermaid Man and Barnacle Boy III ...")

All matches verified against the TVDB web UI's Alternate DVD Order tab.

Credit and thanks to the contributors of jellyfin#226 and jellyfin#242 for identifying
and triaging this bug:
  - foclabroc and drrlvn for reporting the altdvd / alttwo regressions
  - InfiniteLoopGameDev for pointing to the upstream API issue
  - iampegram for proposing and prototyping the per-season fallback
  - TheMelmacian for validating the approach against the API spec
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.

altdvd order not working

1 participant