diff --git a/Shokofin/API/Info/SeasonInfo.cs b/Shokofin/API/Info/SeasonInfo.cs index 34f20bf..09f1bd1 100644 --- a/Shokofin/API/Info/SeasonInfo.cs +++ b/Shokofin/API/Info/SeasonInfo.cs @@ -201,24 +201,26 @@ public SeasonInfo( // We order the lists after sorting them into buckets because the bucket // sort we're doing above have the episodes ordered by air date to get // the previous episode anchors right. - episodesList = episodesList - .OrderBy(e => seriesIdOrder.IndexOf(e.SeriesId)) - .ThenBy(e => e.Type) - .ThenBy(e => e.SeasonNumber) - .ThenBy(e => e.EpisodeNumber) - .ToList(); - specialsList = specialsList - .OrderBy(e => seriesIdOrder.IndexOf(e.SeriesId)) - .ThenBy(e => e.Type) - .ThenBy(e => e.SeasonNumber) - .ThenBy(e => e.EpisodeNumber) - .ToList(); - altEpisodesList = altEpisodesList - .OrderBy(e => seriesIdOrder.IndexOf(e.SeriesId)) - .ThenBy(e => e.Type) - .ThenBy(e => e.SeasonNumber) - .ThenBy(e => e.EpisodeNumber) - .ToList(); + if (!seriesConfigurationMap[seriesId].OrderByAirdate) { + episodesList = episodesList + .OrderBy(e => seriesIdOrder.IndexOf(e.SeriesId)) + .ThenBy(e => e.Type) + .ThenBy(e => e.SeasonNumber) + .ThenBy(e => e.EpisodeNumber) + .ToList(); + altEpisodesList = altEpisodesList + .OrderBy(e => seriesIdOrder.IndexOf(e.SeriesId)) + .ThenBy(e => e.Type) + .ThenBy(e => e.SeasonNumber) + .ThenBy(e => e.EpisodeNumber) + .ToList(); + specialsList = specialsList + .OrderBy(e => seriesIdOrder.IndexOf(e.SeriesId)) + .ThenBy(e => e.Type) + .ThenBy(e => e.SeasonNumber) + .ThenBy(e => e.EpisodeNumber) + .ToList(); + } // Replace the normal episodes if we've hidden all the normal episodes and we have at least one // alternate episode locally. diff --git a/Shokofin/API/ShokoAPIManager.cs b/Shokofin/API/ShokoAPIManager.cs index f797026..786a351 100644 --- a/Shokofin/API/ShokoAPIManager.cs +++ b/Shokofin/API/ShokoAPIManager.cs @@ -151,6 +151,7 @@ public Task GetSeriesConfiguration(string id) MergeOverride = SeriesMergingOverride.None, EpisodesAsSpecials = false, SpecialsAsEpisodes = false, + OrderByAirdate = false, }; var tags = await GetNamespacedTagsForSeries(id); if (!tags.TryGetValue("/custom user tags/shokofin", out var customTags)) @@ -183,6 +184,11 @@ public Task GetSeriesConfiguration(string id) seriesSettings.SpecialsAsEpisodes = false; } + if (tags.ContainsKey("/order by airdate")) + seriesSettings.OrderByAirdate = true; + else if (tags.ContainsKey("/no order by airdate")) + seriesSettings.OrderByAirdate = false; + return seriesSettings; }); diff --git a/Shokofin/Configuration/SeriesConfiguration.cs b/Shokofin/Configuration/SeriesConfiguration.cs index bbe61a8..8f4c996 100644 --- a/Shokofin/Configuration/SeriesConfiguration.cs +++ b/Shokofin/Configuration/SeriesConfiguration.cs @@ -10,4 +10,6 @@ public class SeriesConfiguration public bool EpisodesAsSpecials { get; set; } public bool SpecialsAsEpisodes { get; set; } + + public bool OrderByAirdate { get; set; } }