Skip to content

Commit

Permalink
Fix: Combined Episodes retrieving from same tvdbid for all parts if i…
Browse files Browse the repository at this point in the history
…ts set (#133)
  • Loading branch information
scampower3 authored Apr 6, 2024
1 parent 758ec3d commit 1b69e74
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,15 @@ private async Task<MetadataResult<Episode>> 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);
Expand Down Expand Up @@ -151,7 +158,7 @@ private MetadataResult<Episode> CombineResults(List<MetadataResult<Episode>> res
return result;
}

private async Task<MetadataResult<Episode>> GetEpisode(EpisodeInfo searchInfo, CancellationToken cancellationToken)
private async Task<MetadataResult<Episode>> GetEpisode(EpisodeInfo searchInfo, CancellationToken cancellationToken, bool ignoreTvdbIdField = false)
{
var result = new MetadataResult<Episode>
{
Expand All @@ -161,7 +168,7 @@ private async Task<MetadataResult<Episode>> 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)
Expand Down

0 comments on commit 1b69e74

Please sign in to comment.