mirror of https://github.com/Sonarr/Sonarr
Fixed: Don't produce scene mapping warnings if TheXEM only maps the second half of a season.
This commit is contained in:
parent
74403815d9
commit
e3c4070924
|
@ -60,13 +60,13 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
|
|||
{
|
||||
_theXemSeriesIds.Add(10);
|
||||
|
||||
AddTvdbMapping(1, 1, 1, 1, 1, 1);
|
||||
AddTvdbMapping(2, 1, 2, 2, 1, 2);
|
||||
AddTvdbMapping(3, 2, 1, 3, 2, 1);
|
||||
AddTvdbMapping(4, 2, 2, 4, 2, 2);
|
||||
AddTvdbMapping(5, 2, 3, 5, 2, 3);
|
||||
AddTvdbMapping(6, 3, 1, 6, 2, 4);
|
||||
AddTvdbMapping(7, 3, 2, 7, 2, 5);
|
||||
AddTvdbMapping(1, 1, 1, 1, 1, 1); // 1x01 -> 1x01
|
||||
AddTvdbMapping(2, 1, 2, 2, 1, 2); // 1x02 -> 1x02
|
||||
AddTvdbMapping(3, 2, 1, 3, 2, 1); // 2x01 -> 2x01
|
||||
AddTvdbMapping(4, 2, 2, 4, 2, 2); // 2x02 -> 2x02
|
||||
AddTvdbMapping(5, 2, 3, 5, 2, 3); // 2x03 -> 2x03
|
||||
AddTvdbMapping(6, 3, 1, 6, 2, 4); // 3x01 -> 2x04
|
||||
AddTvdbMapping(7, 3, 2, 7, 2, 5); // 3x02 -> 2x05
|
||||
}
|
||||
|
||||
private void GivenExistingMapping()
|
||||
|
@ -184,6 +184,33 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
|
|||
episode.UnverifiedSceneNumbering.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_flag_past_episodes_if_not_causing_overlaps()
|
||||
{
|
||||
GivenTvdbMappings();
|
||||
_theXemTvdbMappings.RemoveAll(v => v.Scene.Season == 2);
|
||||
|
||||
Subject.Handle(new SeriesUpdatedEvent(_series));
|
||||
|
||||
var episode = _episodes.First(v => v.SeasonNumber == 2 && v.EpisodeNumber == 1);
|
||||
|
||||
episode.UnverifiedSceneNumbering.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_flag_past_episodes_if_causing_overlap()
|
||||
{
|
||||
GivenTvdbMappings();
|
||||
_theXemTvdbMappings.RemoveAll(v => v.Scene.Season == 2 && v.Tvdb.Episode <= 1);
|
||||
_theXemTvdbMappings.First(v => v.Scene.Season == 2 && v.Scene.Episode == 2).Scene.Episode = 1;
|
||||
|
||||
Subject.Handle(new SeriesUpdatedEvent(_series));
|
||||
|
||||
var episode = _episodes.First(v => v.SeasonNumber == 2 && v.EpisodeNumber == 1);
|
||||
|
||||
episode.UnverifiedSceneNumbering.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_extrapolate_season_with_specials()
|
||||
{
|
||||
|
|
|
@ -92,6 +92,13 @@ namespace NzbDrone.Core.DataAugmentation.Xem
|
|||
{
|
||||
var mappedEpisodes = episodes.Where(v => v.SeasonNumber != 0 && v.SceneEpisodeNumber.HasValue).ToList();
|
||||
var mappedSeasons = new HashSet<int>(mappedEpisodes.Select(v => v.SeasonNumber).Distinct());
|
||||
|
||||
var sceneEpisodeMappings = mappings.ToLookup(v => v.Scene.Season)
|
||||
.ToDictionary(v => v.Key, e => new HashSet<int>(e.Select(v => v.Scene.Episode)));
|
||||
|
||||
var firstTvdbEpisodeBySeason = mappings.ToLookup(v => v.Tvdb.Season)
|
||||
.ToDictionary(v => v.Key, e => e.Min(v => v.Tvdb.Episode));
|
||||
|
||||
var lastSceneSeason = mappings.Select(v => v.Scene.Season).Max();
|
||||
var lastTvdbSeason = mappings.Select(v => v.Tvdb.Season).Max();
|
||||
|
||||
|
@ -103,10 +110,22 @@ namespace NzbDrone.Core.DataAugmentation.Xem
|
|||
|
||||
if (mappedSeasons.Contains(episode.SeasonNumber))
|
||||
{
|
||||
episode.UnverifiedSceneNumbering = true;
|
||||
}
|
||||
// Mark if a mapping exists for an earlier episode in this season.
|
||||
if (firstTvdbEpisodeBySeason[episode.SeasonNumber] <= episode.EpisodeNumber)
|
||||
{
|
||||
episode.UnverifiedSceneNumbering = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lastSceneSeason != lastTvdbSeason && episode.SeasonNumber > lastTvdbSeason)
|
||||
// Mark if a mapping exists with a scene number to this episode.
|
||||
if (sceneEpisodeMappings.ContainsKey(episode.SeasonNumber) &&
|
||||
sceneEpisodeMappings[episode.SeasonNumber].Contains(episode.EpisodeNumber))
|
||||
{
|
||||
episode.UnverifiedSceneNumbering = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (lastSceneSeason != lastTvdbSeason && episode.SeasonNumber > lastTvdbSeason)
|
||||
{
|
||||
episode.UnverifiedSceneNumbering = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue