|
|
@ -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;
|
|
|
|
|
|
|
|
|
|
|
|
// Add 1 to to non-specials to account for AirsBeforeEpisodeNumber
|
|
|
|
// Special comes before the season
|
|
|
|
var xEpisode = x.IndexNumber ?? -1;
|
|
|
|
if (!yEpisode.HasValue)
|
|
|
|
xEpisode++;
|
|
|
|
{
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var yEpisode = y.AirsBeforeEpisodeNumber ?? 10000;
|
|
|
|
// Compare episode number
|
|
|
|
|
|
|
|
var xEpisode = x.IndexNumber;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|