Repository navigation
fix(shoko): resolve series episode/movie cross-references by anime id - #1453
Merged
Merged
Conversation
AnimeSeries exposed ISeries.MetadataEpisodeCrossReferences and ISeries.MetadataMovieCrossReferences by calling the per-episode lookups (GetEpisodeCrossReferences / GetMovieCrossReferences) with the series' AniDB *anime* id. Those methods are keyed by AniDB episode id, so the result was empty (or, when an unrelated AniDB episode happens to share the id, wrong). The sibling MetadataSeriesCrossReferences / MetadataSeasonCrossReferences properties and AniDB_Anime already use the series-scoped overloads; do the same here with GetEpisodeCrossReferencesForSeries / GetMovieCrossReferencesForSeries. This restores the episode<->AniDB mapping consumed by relocation/rename providers (e.g. LuaRenamer's TmdbToModel), which otherwise lose the link and fall back to season 1 for sequel anime. Regression introduced in afe0455.
revam
approved these changes
Oct 10, 2026
|
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
AnimeSeries— theISeriesimplementation backed by a Shoko series — exposes its episode-level and film-level cross-references by calling the per-episode lookups with the series' AniDB anime id:GetEpisodeCrossReferences/GetMovieCrossReferencesare keyed by an AniDB episode id, so passing an anime id returns essentially nothing — or, worse, cross-references belonging to the unrelated AniDB episode whose id happens to equal this anime id.The sibling
MetadataSeriesCrossReferencesandMetadataSeasonCrossReferencesproperties correctly use the series-scoped lookups (GetSeriesCrossReferences/GetSeasonCrossReferences), andAniDB_Animealready usesGetEpisodeCrossReferencesForSeries. Only these two lines use the wrong scope.Root cause
A regression introduced in afe0455 ("refactor: my third most evilest commit to date"), which added the
ISeries.Metadata*CrossReferencessurface and gaveAnimeSeriesthe per-episode overload instead of the per-anime one.Impact
Every consumer of
ISeries.MetadataEpisodeCrossReferences/MetadataMovieCrossReferenceson a Shoko series:TmdbToModel(ModelProducers.cs) readsseries.GetEpisodeCrossReferences(MetadataSource.TMDB)to map TMDB episodes back to the AniDB episodes of the series. With this returning empty, each TMDB episode'sanidbepisodeidsis empty; the rename script loses the episode↔AniDB link and falls back toseasonnumber or 1. A "season 2" episode of a sequel anime is therefore renamed and filed into Season 01. (The series folder is still correct, because it comes from the series/anime id — only the season level is wrong, which is why it is so easy to miss.)GET /api/v3/Metadata/Shoko/Series/{id}/Episode/CrossReferencesand.../Movie/CrossReferences.Evidence
Reproduced on a live server (alpha.102, matching
6b4bfca9d) with Saga of Tanya the Evil — AniDB S1 = Shoko series 1243 / anime 11905, S2 = series 19964 / anime 16392, both linking TMDB show 69346:GET /api/v3/Series/19964/Metadata/TMDB/CrossReferences/Episode(viaGetEpisodeCrossReferencesForSeries)SeasonNumber = 2GET /api/v3/Metadata/Shoko/Series/19964/Episode/CrossReferences(via the broken property){"Total": 0, "List": []}GET /api/v3/Metadata/Shoko/Series/1243/Episode/CrossReferencesA relocation-preview debug of the S2 file logged:
The TMDB link is correct (season 2), but the AniDB episode list is empty — exactly what drives the renamer to
Season 01.The fix
Use the series-scoped overloads:
This matches:
MetadataSeasonCrossReferencesis already built (from the series' episode links);AniDB_Animealready uses;GetMovieCrossReferencesForSeriesitself — "Looks up the film-level cross-references across a whole anime."Behaviour for a provider-side series (where
AniDB_IDis0) is unchanged: both methods guardanidbAnimeID <= 0and return an empty list.Scope of change
Two lines in
Shoko.Server/Models/Shoko/AnimeSeries.cs. No abstractions or public API signatures change;AnimeSeasonandAnimeEpisodeare unaffected (they build their references from the per-episode ones, which is correct).Testing
dotnet build Shoko.Server/Shoko.Server.csproj— succeeds with the change.GET /api/v3/Metadata/Shoko/Series/19964/Episode/CrossReferencesreturns the same 24 links as the TMDB route, and a relocation preview of the S2 file resolves toSeason 02/S02E01instead ofSeason 01/S01E01.