From fa261c55f26f6d21480d0c7ca8a6d93a5c6413c7 Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Mon, 7 Oct 2024 03:59:55 +0200 Subject: [PATCH] fix: fix episode parent series field usage - Added a temporary workaround for the stable server not supporting sending the parent series id with the episodes. It was added _15 days_ after the last stable. So I thought it was in, but apparently it wasn't. --- Shokofin/API/ShokoAPIClient.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Shokofin/API/ShokoAPIClient.cs b/Shokofin/API/ShokoAPIClient.cs index 8e4a4ae9..c4e58a53 100644 --- a/Shokofin/API/ShokoAPIClient.cs +++ b/Shokofin/API/ShokoAPIClient.cs @@ -25,6 +25,11 @@ public class ShokoAPIClient : IDisposable private static ComponentVersion? ServerVersion => Plugin.Instance.Configuration.ServerVersion; + private static readonly DateTime EpisodeSeriesParentAddedDate = DateTime.Parse("2023-04-17T00:00:00.000Z"); + + private static bool UseEpisodeGetSeriesEndpoint => + ServerVersion != null && ((ServerVersion.ReleaseChannel == ReleaseChannel.Stable && ServerVersion.Version == new Version("4.2.2.0")) || (ServerVersion.ReleaseDate.HasValue && ServerVersion.ReleaseDate.Value < EpisodeSeriesParentAddedDate)); + private static readonly DateTime StableCutOffDate = DateTime.Parse("2023-12-16T00:00:00.000Z"); private static bool UseOlderSeriesAndFileEndpoints => @@ -348,7 +353,13 @@ public Task GetEpisode(string id) // If the episode has no 'movie' images, get the series images to compensate. if (episodeImages.Posters.Count is 0) { var episode1 = await GetEpisode(id); - var seriesImages1 = await GetSeriesImages(episode1.IDs.ParentSeries.ToString()) ?? new(); + var seriesId = episode1.IDs.ParentSeries.ToString(); + if (UseEpisodeGetSeriesEndpoint) { + var series = await GetSeriesFromEpisode(id); + if (series != null) + seriesId = series.IDs.Shoko.ToString(); + } + var seriesImages1 = seriesId is not "0" ? await GetSeriesImages(seriesId) ?? new() : new(); episodeImages.Posters = seriesImages1.Posters; episodeImages.Logos = seriesImages1.Logos;