|
|
@ -80,25 +80,36 @@ namespace MediaBrowser.Server.Implementations.Sorting
|
|
|
|
return xSeason.CompareTo(ySeason);
|
|
|
|
return 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
|
|
|
|
// Compare episode number
|
|
|
|
var xEpisode = x.IndexNumber ?? -1;
|
|
|
|
var xEpisode = x.IndexNumber;
|
|
|
|
xEpisode++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var yEpisode = y.AirsBeforeEpisodeNumber ?? 10000;
|
|
|
|
if (!xEpisode.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Can't really compare if this happens
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Sometimes they'll both have a value.
|
|
|
|
// Special comes before episode
|
|
|
|
// For example AirsAfterSeasonNumber=1, AirsBeforeSeasonNumber=2, AirsBeforeEpisodeNumber=1
|
|
|
|
if (xEpisode.Value == yEpisode.Value)
|
|
|
|
// The episode should be displayed at the end of season 1
|
|
|
|
|
|
|
|
if (y.AirsAfterSeasonNumber.HasValue && y.AirsBeforeSeasonNumber.HasValue && y.AirsBeforeSeasonNumber.Value > y.AirsAfterSeasonNumber.Value)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
yEpisode = 10000;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return xEpisode.CompareTo(yEpisode);
|
|
|
|
return xEpisode.Value.CompareTo(yEpisode.Value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int CompareSpecials(Episode x, Episode y)
|
|
|
|
private int CompareSpecials(Episode x, Episode y)
|
|
|
|