From f75668605b668e4bdc9509e3355bb91edf8eb49f Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Mon, 9 Sep 2024 03:46:37 +0200 Subject: [PATCH] fix: use all episodes if the anime is an OVA --- Shoko.Server/Providers/TMDB/TmdbLinkingService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Shoko.Server/Providers/TMDB/TmdbLinkingService.cs b/Shoko.Server/Providers/TMDB/TmdbLinkingService.cs index 438cbebc2..b03b83474 100644 --- a/Shoko.Server/Providers/TMDB/TmdbLinkingService.cs +++ b/Shoko.Server/Providers/TMDB/TmdbLinkingService.cs @@ -396,6 +396,7 @@ public IReadOnlyList MatchAnidbToTmdbEpisodes(int a _logger.LogTrace("Mapping AniDB Anime {AnidbAnimeId} to TMDB Show {TmdbShowId} (Season: {TmdbSeasonId}, Use Existing: {UseExisting}, Save To Database: {SaveToDatabase})", anidbAnimeId, tmdbShowId, tmdbSeasonId, useExisting, saveToDatabase); // Mapping logic + var isOVA = anime.AbstractAnimeType is AnimeType.OVA; var toSkip = new HashSet(); var toAdd = new List(); var crossReferences = new List(); @@ -410,12 +411,12 @@ public IReadOnlyList MatchAnidbToTmdbEpisodes(int a var tmdbEpisodes = _tmdbEpisodes.GetByTmdbShowID(tmdbShowId) .Where(episode => episode.SeasonNumber == 0 || !tmdbSeasonId.HasValue || episode.TmdbSeasonID == tmdbSeasonId.Value) .ToList(); - var tmdbNormalEpisodes = tmdbEpisodes + var tmdbNormalEpisodes = isOVA ? tmdbEpisodes : tmdbEpisodes .Where(episode => episode.SeasonNumber != 0) .OrderBy(episode => episode.SeasonNumber) .ThenBy(episode => episode.EpisodeNumber) .ToList(); - var tmdbSpecialEpisodes = tmdbEpisodes + var tmdbSpecialEpisodes = isOVA ? tmdbEpisodes : tmdbEpisodes .Where(episode => episode.SeasonNumber == 0) .OrderBy(episode => episode.EpisodeNumber) .ToList(); @@ -480,8 +481,8 @@ public IReadOnlyList MatchAnidbToTmdbEpisodes(int a // Else try find a match. _logger.LogTrace("Linking episode {EpisodeID}", episode.EpisodeID); var isSpecial = episode.AbstractEpisodeType is EpisodeType.Special || anime.AbstractAnimeType is not AnimeType.TVSeries and not AnimeType.Web; - var episodeList = isSpecial ? tmdbSpecialEpisodes : tmdbNormalEpisodes; - var crossRef = TryFindAnidbAndTmdbMatch(anime, episode, episodeList, isSpecial); + var episodeList = isOVA ? tmdbEpisodes : isSpecial ? tmdbSpecialEpisodes : tmdbNormalEpisodes; + var crossRef = TryFindAnidbAndTmdbMatch(anime, episode, episodeList, isSpecial && !isOVA); if (crossRef.TmdbEpisodeID != 0) { _logger.LogTrace("Found match for episode {EpisodeID} (TMDB ID: {TMDbEpisodeID})", episode.EpisodeID, crossRef.TmdbEpisodeID);