Skip to content

Commit

Permalink
fix: fix episode parent series field usage
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
revam committed Oct 7, 2024
1 parent 1414bb0 commit fa261c5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Shokofin/API/ShokoAPIClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down Expand Up @@ -348,7 +353,13 @@ public Task<Episode> 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;
Expand Down

0 comments on commit fa261c5

Please sign in to comment.