Work around TVDB API bug for altdvd / alttwo season types (fixes #226)#246
Open
superuser404notfound wants to merge 1 commit into
Open
Work around TVDB API bug for altdvd / alttwo season types (fixes #226)#246superuser404notfound wants to merge 1 commit into
superuser404notfound wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #226 by working around thetvdb/v4-api#340 where the TVDB v4 API returns an empty
episodesarray for thealtdvdandalttwoseason 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
GetSeriesEpisodesAsynccall comes back empty, walk the extended series record, filterSeasonsbySeasonType.Type, and aggregate each matching season'sEpisodesvia the existingIExtendedSeasonClient(GetSeasonByIdAsync). No new DI wiring is needed.The same workaround is also applied at the
GetEpisodeTvdbIdentry point. The SDK's filter-by-SxE variant of the bulk endpoint is broken for the same season types, soTvdbEpisodeProvider.GetEpisodewas 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/numberfields returned by/seasons/{id}/extendedare 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:
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 = seasonTypeassignment 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
TreatWarningsAsErrorsand the existing StyleCop / nullability analyzers.