The Free Software Media System - Server Backend & API
fixed special episode sorting
Luke Pulverenti4b4c5635af8e
diff --git a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.csindex d6b78bd84b..8707f2e5bb 100644--- a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs+++ b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs@@ -80,25 +80,36 @@ namespace MediaBrowser.Server.Implementations.Sortingreturn xSeason.CompareTo(ySeason);}- // Now we know they have the same season+ // Special comes after episode+ if (y.AirsAfterSeasonNumber.HasValue)+ {+ return -1;+ }- // Compare episode number+ var yEpisode = y.AirsBeforeEpisodeNumber;++ // Special comes before the season+ if (!yEpisode.HasValue)+ {+ return 1;+ }- // Add 1 to to non-specials to account for AirsBeforeEpisodeNumber- var xEpisode = x.IndexNumber ?? -1;- xEpisode++;+ // Compare episode number+ var xEpisode = x.IndexNumber;- var yEpisode = y.AirsBeforeEpisodeNumber ?? 10000;+ if (!xEpisode.HasValue)+ {+ // Can't really compare if this happens+ return 0;+ }- // Sometimes they'll both have a value.- // For example AirsAfterSeasonNumber=1, AirsBeforeSeasonNumber=2, AirsBeforeEpisodeNumber=1- // The episode should be displayed at the end of season 1- if (y.AirsAfterSeasonNumber.HasValue && y.AirsBeforeSeasonNumber.HasValue && y.AirsBeforeSeasonNumber.Value > y.AirsAfterSeasonNumber.Value)+ // Special comes before episode+ if (xEpisode.Value == yEpisode.Value){- yEpisode = 10000;+ return 1;}- return xEpisode.CompareTo(yEpisode);+ return xEpisode.Value.CompareTo(yEpisode.Value);}private int CompareSpecials(Episode x, Episode y)