mirror of https://github.com/Sonarr/Sonarr
New: Prefer regular episodes over specials when absolute numbers conflict
Closes #676
This commit is contained in:
parent
2396af4589
commit
1603b06431
|
@ -365,5 +365,33 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
|
||||
_insertedEpisodes.Should().OnlyContain(e => e.AirDateUtc.Value.ToString("s") == episodes.First().AirDateUtc.Value.ToString("s"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_prefer_regular_season_when_absolute_numbers_conflict()
|
||||
{
|
||||
var episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
episodes[0].AbsoluteEpisodeNumber = episodes[1].AbsoluteEpisodeNumber;
|
||||
episodes[0].SeasonNumber = 0;
|
||||
episodes[0].EpisodeNumber.Should().NotBe(episodes[1].EpisodeNumber);
|
||||
|
||||
var existingEpisode = new Episode
|
||||
{
|
||||
SeasonNumber = episodes[0].SeasonNumber,
|
||||
EpisodeNumber = episodes[0].EpisodeNumber,
|
||||
AbsoluteEpisodeNumber = episodes[1].AbsoluteEpisodeNumber
|
||||
};
|
||||
|
||||
Mocker.GetMock<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<int>()))
|
||||
.Returns(new List<Episode> { existingEpisode });
|
||||
|
||||
Subject.RefreshEpisodeInfo(GetAnimeSeries(), episodes);
|
||||
|
||||
_updatedEpisodes.First().SeasonNumber.Should().Be(episodes[1].SeasonNumber);
|
||||
_updatedEpisodes.First().EpisodeNumber.Should().Be(episodes[1].EpisodeNumber);
|
||||
_updatedEpisodes.First().AbsoluteEpisodeNumber.Should().Be(episodes[1].AbsoluteEpisodeNumber);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ namespace NzbDrone.Core.Tv
|
|||
|
||||
if (series.SeriesType == SeriesTypes.Anime)
|
||||
{
|
||||
dupeFreeRemoteEpisodes = MapAbsoluteEpisodeNumbers(series, dupeFreeRemoteEpisodes);
|
||||
dupeFreeRemoteEpisodes = MapAbsoluteEpisodeNumbers(dupeFreeRemoteEpisodes);
|
||||
}
|
||||
|
||||
foreach (var episode in OrderEpisodes(series, dupeFreeRemoteEpisodes))
|
||||
|
@ -154,13 +154,14 @@ namespace NzbDrone.Core.Tv
|
|||
}
|
||||
}
|
||||
|
||||
private List<Episode> MapAbsoluteEpisodeNumbers(Series series, List<Episode> traktEpisodes)
|
||||
private List<Episode> MapAbsoluteEpisodeNumbers(List<Episode> remoteEpisodes)
|
||||
{
|
||||
//Return all episodes with no abs number, but distinct for those with abs number
|
||||
return traktEpisodes.Where(e => e.AbsoluteEpisodeNumber.HasValue)
|
||||
.DistinctBy(e => e.AbsoluteEpisodeNumber.Value)
|
||||
.Concat(traktEpisodes.Where(e => !e.AbsoluteEpisodeNumber.HasValue))
|
||||
.ToList();
|
||||
return remoteEpisodes.Where(e => e.AbsoluteEpisodeNumber.HasValue)
|
||||
.OrderByDescending(e => e.SeasonNumber)
|
||||
.DistinctBy(e => e.AbsoluteEpisodeNumber.Value)
|
||||
.Concat(remoteEpisodes.Where(e => !e.AbsoluteEpisodeNumber.HasValue))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private Episode GetEpisodeToUpdate(Series series, Episode episode, List<Episode> existingEpisodes)
|
||||
|
|
Loading…
Reference in New Issue