Skip to content

Commit

Permalink
Added PR jellyfin#91 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
scampower3 committed Aug 13, 2023
1 parent 8efb0d6 commit 3e43a2d
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions Jellyfin.Plugin.Tvdb/TvdbClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ public async Task<TvDbApiResponse<ArtworkTypeDto[]>> GetArtworkTypeAsync(Cancell
{
searchInfo.SeriesProviderIds.TryGetValue(TvdbPlugin.ProviderId, out var seriesTvdbId);
SeriesEpisodesOptionalParams episodeQuery = new SeriesEpisodesOptionalParams();
bool special = false;
// Prefer SxE over premiere date as it is more robust
if (searchInfo.IndexNumber.HasValue && searchInfo.ParentIndexNumber.HasValue)
{
Expand All @@ -348,7 +349,16 @@ public async Task<TvDbApiResponse<ArtworkTypeDto[]>> GetArtworkTypeAsync(Cancell
episodeQuery.Season = searchInfo.ParentIndexNumber.Value;
break;
case "absolute":
episodeQuery.Season = 1; // absolute order is always season 1
if (searchInfo.ParentIndexNumber.Value == 0) // check if special
{
special = true;
episodeQuery.Season = 0;
}
else
{
episodeQuery.Season = 1; // absolute order is always season 1
}

episodeQuery.EpisodeNumber = searchInfo.IndexNumber.Value;
break;
default:
Expand All @@ -367,16 +377,22 @@ public async Task<TvDbApiResponse<ArtworkTypeDto[]>> GetArtworkTypeAsync(Cancell
episodeQuery.Page = 0;
var tvDbClient = await GetTvDbClient(language).ConfigureAwait(false);
TvDbApiResponse<GetSeriesEpisodesResponseData> apiResponse;
// Not using TryGetValue since it returns the wrong value.
switch (searchInfo.SeriesDisplayOrder)
if (!special)
{
switch (searchInfo.SeriesDisplayOrder)
{
case "dvd":
case "absolute":
apiResponse = await tvDbClient.SeriesEpisodes(Convert.ToInt32(seriesTvdbId, CultureInfo.InvariantCulture), searchInfo.SeriesDisplayOrder, episodeQuery, cancellationToken).ConfigureAwait(false);
break;
default:
apiResponse = await tvDbClient.SeriesEpisodes(Convert.ToInt32(seriesTvdbId, CultureInfo.InvariantCulture), "default", episodeQuery, cancellationToken).ConfigureAwait(false);
break;
}
}
else // when special use default order
{
case "dvd":
case "absolute":
apiResponse = await tvDbClient.SeriesEpisodes(Convert.ToInt32(seriesTvdbId, CultureInfo.InvariantCulture), searchInfo.SeriesDisplayOrder, episodeQuery, cancellationToken).ConfigureAwait(false);
break;
default:
apiResponse = await tvDbClient.SeriesEpisodes(Convert.ToInt32(seriesTvdbId, CultureInfo.InvariantCulture), "default", episodeQuery, cancellationToken).ConfigureAwait(false);
break;
apiResponse = await tvDbClient.SeriesEpisodes(Convert.ToInt32(seriesTvdbId, CultureInfo.InvariantCulture), "default", episodeQuery, cancellationToken).ConfigureAwait(false);
}

GetSeriesEpisodesResponseData apiData = apiResponse.Data;
Expand Down

0 comments on commit 3e43a2d

Please sign in to comment.