diff --git a/Shokofin/API/Info/ShowInfo.cs b/Shokofin/API/Info/ShowInfo.cs index b0fc71d8..5958739b 100644 --- a/Shokofin/API/Info/ShowInfo.cs +++ b/Shokofin/API/Info/ShowInfo.cs @@ -55,7 +55,7 @@ public class ShowInfo /// /// Ended date of the show. /// - public DateTime? EndDate => + public DateTime? EndDate => SeasonList.Any(s => s.AniDB.EndDate == null) ? null : SeasonList .Select(s => s.AniDB.AirDate) .OrderBy(s => s) @@ -190,6 +190,7 @@ public ShowInfo(Group group, List seasonList, ILogger logger, bool u seasonList = seasonList.OrderBy(s => s?.AniDB?.AirDate ?? DateTime.MaxValue).ToList(); break; case Ordering.OrderType.Chronological: + case Ordering.OrderType.ChronologicalIgnoreIndirect: seasonList.Sort(new SeriesInfoRelationComparer()); break; } @@ -201,11 +202,11 @@ public ShowInfo(Group group, List seasonList, ILogger logger, bool u foundIndex = 0; break; case Ordering.OrderType.Default: - case Ordering.OrderType.Chronological: { + case Ordering.OrderType.Chronological: + case Ordering.OrderType.ChronologicalIgnoreIndirect: int targetId = group.IDs.MainSeries; foundIndex = seasonList.FindIndex(s => s.Shoko.IDs.Shoko == targetId); break; - } } // Fallback to the first series if we can't get a base point for seasons. diff --git a/Shokofin/Configuration/configPage.html b/Shokofin/Configuration/configPage.html index 048ef7e3..f17df8a9 100644 --- a/Shokofin/Configuration/configPage.html +++ b/Shokofin/Configuration/configPage.html @@ -164,7 +164,8 @@

Library Settings

Determines how to order seasons within each show using the Shoko groups.
diff --git a/Shokofin/Utils/Ordering.cs b/Shokofin/Utils/Ordering.cs index d2feb977..b014e3dc 100644 --- a/Shokofin/Utils/Ordering.cs +++ b/Shokofin/Utils/Ordering.cs @@ -49,6 +49,11 @@ public enum OrderType /// Order seasons based on the chronological order of relations. /// Chronological = 2, + + /// + /// Order seasons based on the chronological order of only direct relations. + /// + ChronologicalIgnoreIndirect = 3, } public enum SpecialOrderType { diff --git a/Shokofin/Utils/SeriesInfoRelationComparer.cs b/Shokofin/Utils/SeriesInfoRelationComparer.cs index 6560fe0a..8b38d18e 100644 --- a/Shokofin/Utils/SeriesInfoRelationComparer.cs +++ b/Shokofin/Utils/SeriesInfoRelationComparer.cs @@ -40,9 +40,12 @@ public int Compare(SeasonInfo? a, SeasonInfo? b) return directRelationComparison; // Check for indirect relations. - var indirectRelationComparison = CompareIndirectRelations(a, b); - if (indirectRelationComparison != 0) - return indirectRelationComparison; + if (Plugin.Instance.Configuration.SeasonOrdering != Ordering.OrderType.ChronologicalIgnoreIndirect) + { + var indirectRelationComparison = CompareIndirectRelations(a, b); + if (indirectRelationComparison != 0) + return indirectRelationComparison; + } // Fallback to checking the air dates if they're not indirectly related // or if they have the same relations.