mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
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 @@ public void should_not_update_air_date_when_multiple_episodes_air_on_the_same_da
|
|||||||
|
|
||||||
_insertedEpisodes.Should().OnlyContain(e => e.AirDateUtc.Value.ToString("s") == episodes.First().AirDateUtc.Value.ToString("s"));
|
_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 @@ public void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisode
|
|||||||
|
|
||||||
if (series.SeriesType == SeriesTypes.Anime)
|
if (series.SeriesType == SeriesTypes.Anime)
|
||||||
{
|
{
|
||||||
dupeFreeRemoteEpisodes = MapAbsoluteEpisodeNumbers(series, dupeFreeRemoteEpisodes);
|
dupeFreeRemoteEpisodes = MapAbsoluteEpisodeNumbers(dupeFreeRemoteEpisodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var episode in OrderEpisodes(series, dupeFreeRemoteEpisodes))
|
foreach (var episode in OrderEpisodes(series, dupeFreeRemoteEpisodes))
|
||||||
@ -154,12 +154,13 @@ private void AdjustDirectToDvdAirDate(Series series, IEnumerable<Episode> allEpi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 all episodes with no abs number, but distinct for those with abs number
|
||||||
return traktEpisodes.Where(e => e.AbsoluteEpisodeNumber.HasValue)
|
return remoteEpisodes.Where(e => e.AbsoluteEpisodeNumber.HasValue)
|
||||||
|
.OrderByDescending(e => e.SeasonNumber)
|
||||||
.DistinctBy(e => e.AbsoluteEpisodeNumber.Value)
|
.DistinctBy(e => e.AbsoluteEpisodeNumber.Value)
|
||||||
.Concat(traktEpisodes.Where(e => !e.AbsoluteEpisodeNumber.HasValue))
|
.Concat(remoteEpisodes.Where(e => !e.AbsoluteEpisodeNumber.HasValue))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user