Skip to content

Commit

Permalink
feat: add series config. option to order by airdate
Browse files Browse the repository at this point in the history
This option will only make sense if you enable the other series config. to include specials as episodes.
  • Loading branch information
revam committed Nov 21, 2024
1 parent a794815 commit 37e6305
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Shokofin/API/Info/SeasonInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions Shokofin/API/ShokoAPIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public Task<SeriesConfiguration> 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))
Expand Down Expand Up @@ -183,6 +184,11 @@ public Task<SeriesConfiguration> 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;
});

Expand Down
2 changes: 2 additions & 0 deletions Shokofin/Configuration/SeriesConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public class SeriesConfiguration
public bool EpisodesAsSpecials { get; set; }

public bool SpecialsAsEpisodes { get; set; }

public bool OrderByAirdate { get; set; }
}

0 comments on commit 37e6305

Please sign in to comment.