From 1b69e74138635e482cab25a15297885948d0b977 Mon Sep 17 00:00:00 2001 From: scampower3 <81431263+scampower3@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:18:07 +0800 Subject: [PATCH] Fix: Combined Episodes retrieving from same tvdbid for all parts if its set (#133) --- .../Providers/TvdbEpisodeProvider.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs index e158ea8..9d707c7 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs @@ -116,8 +116,15 @@ private async Task> GetCombinedEpisode(EpisodeInfo info, { var tempEpisodeInfo = info; info.IndexNumber = episode; - - results.Add(await GetEpisode(tempEpisodeInfo, cancellationToken).ConfigureAwait(false)); + // First step in the loop, try use the tvdbid field. Else, ignore the field + if (episode == startIndex) + { + results.Add(await GetEpisode(tempEpisodeInfo, cancellationToken).ConfigureAwait(false)); + } + else + { + results.Add(await GetEpisode(tempEpisodeInfo, cancellationToken, true).ConfigureAwait(false)); + } } var result = CombineResults(results); @@ -151,7 +158,7 @@ private MetadataResult CombineResults(List> res return result; } - private async Task> GetEpisode(EpisodeInfo searchInfo, CancellationToken cancellationToken) + private async Task> GetEpisode(EpisodeInfo searchInfo, CancellationToken cancellationToken, bool ignoreTvdbIdField = false) { var result = new MetadataResult { @@ -161,7 +168,7 @@ private async Task> GetEpisode(EpisodeInfo searchInfo, C var episodeTvdbId = searchInfo.GetTvdbId().ToString(CultureInfo.InvariantCulture); try { - if (string.Equals(episodeTvdbId, "0", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(episodeTvdbId, "0", StringComparison.OrdinalIgnoreCase) || ignoreTvdbIdField) { episodeTvdbId = await _tvdbClientManager .GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken)