Fixed: Some anime season 1 parsing

pull/233/merge
Mark McDowall 10 years ago
parent cfefed34fc
commit 62f4fc5e58

@ -77,6 +77,8 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("[Jumonji-Giri]_[F-B]_Kagihime_Monogatari_Eikyuu_Alice_Rondo_Ep08_(8246e542).mkv", "Kagihime Monogatari Eikyuu Alice Rondo", 8, 0, 0)]
[TestCase("Knights of Sidonia - 01 [1080p 10b DTSHD-MA eng sub].mkv", "Knights of Sidonia", 1, 0, 0)]
[TestCase("Series Title (2010) {01} Episode Title (1).hdtv-720p", "Series Title (2010)", 1, 0, 0)]
[TestCase("[Hatsuyuki] Dragon Ball Kai (2014) - 017 (115) [1280x720][B2CFBC0F]", "Dragon Ball Kai 2014", 17, 0, 0)]
[TestCase("[Hatsuyuki] Dragon Ball Kai (2014) - 018 (116) [1280x720][C4A3B16E]", "Dragon Ball Kai 2014", 18, 0, 0)]
//[TestCase("", "", 0, 0, 0)]
public void should_parse_absolute_numbers(string postTitle, string title, int absoluteEpisodeNumber, int seasonNumber, int episodeNumber)
{

@ -187,41 +187,91 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
}
[Test]
public void should_use_scene_numbering_when_season_0_for_anime()
public void should_look_for_episode_in_season_zero_if_absolute_special()
{
GivenAbsoluteNumberingSeries();
_parsedEpisodeInfo.Special = true;
Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null);
Mocker.GetMock<IEpisodeService>()
.Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), 0, It.IsAny<Int32>()), Times.Never());
Mocker.GetMock<IEpisodeService>()
.Verify(v => v.FindEpisode(It.IsAny<Int32>(), 0, It.IsAny<Int32>()), Times.Once());
}
[TestCase(0)]
[TestCase(1)]
[TestCase(2)]
public void should_use_scene_numbering_when_scene_season_number_has_value(int seasonNumber)
{
GivenAbsoluteNumberingSeries();
Mocker.GetMock<ISceneMappingService>()
.Setup(s => s.GetSeasonNumber(_parsedEpisodeInfo.SeriesTitle))
.Returns(0);
.Returns(seasonNumber);
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), 0, It.IsAny<Int32>()))
.Setup(s => s.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), seasonNumber, It.IsAny<Int32>()))
.Returns(new List<Episode>());
Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null);
Mocker.GetMock<IEpisodeService>()
.Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), 0, It.IsAny<Int32>()), Times.Once());
.Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), seasonNumber, It.IsAny<Int32>()), Times.Once());
Mocker.GetMock<IEpisodeService>()
.Verify(v => v.FindEpisode(It.IsAny<Int32>(), 0, It.IsAny<Int32>()), Times.Once());
.Verify(v => v.FindEpisode(It.IsAny<Int32>(), seasonNumber, It.IsAny<Int32>()), Times.Once());
}
[Test]
public void should_look_for_episode_in_season_zero_if_absolute_special()
[TestCase(0)]
[TestCase(1)]
[TestCase(2)]
public void should_find_episode_by_season_and_scene_absolute_episode_number(int seasonNumber)
{
GivenAbsoluteNumberingSeries();
_parsedEpisodeInfo.Special = true;
Mocker.GetMock<ISceneMappingService>()
.Setup(s => s.GetSeasonNumber(_parsedEpisodeInfo.SeriesTitle))
.Returns(seasonNumber);
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), seasonNumber, It.IsAny<Int32>()))
.Returns(new List<Episode> { _episodes.First() });
Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null);
Mocker.GetMock<IEpisodeService>()
.Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), 0, It.IsAny<Int32>()), Times.Never());
.Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), seasonNumber, It.IsAny<Int32>()), Times.Once());
Mocker.GetMock<IEpisodeService>()
.Verify(v => v.FindEpisode(It.IsAny<Int32>(), 0, It.IsAny<Int32>()), Times.Once());
.Verify(v => v.FindEpisode(It.IsAny<Int32>(), seasonNumber, It.IsAny<Int32>()), Times.Never());
}
[TestCase(0)]
[TestCase(1)]
[TestCase(2)]
public void should_find_episode_by_season_and_absolute_episode_number_when_scene_absolute_episode_number_returns_multiple_results(int seasonNumber)
{
GivenAbsoluteNumberingSeries();
Mocker.GetMock<ISceneMappingService>()
.Setup(s => s.GetSeasonNumber(_parsedEpisodeInfo.SeriesTitle))
.Returns(seasonNumber);
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), seasonNumber, It.IsAny<Int32>()))
.Returns(Builder<Episode>.CreateListOfSize(5).Build().ToList());
Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null);
Mocker.GetMock<IEpisodeService>()
.Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny<Int32>(), seasonNumber, It.IsAny<Int32>()), Times.Once());
Mocker.GetMock<IEpisodeService>()
.Verify(v => v.FindEpisode(It.IsAny<Int32>(), seasonNumber, It.IsAny<Int32>()), Times.Once());
}
}
}

@ -188,7 +188,10 @@ namespace NzbDrone.Core.Parser
else if (sceneSource)
{
if (sceneSeasonNumber.HasValue && (sceneSeasonNumber == 0 || sceneSeasonNumber > 1))
// Is there a reason why we excluded season 1 from this handling before?
// Might have something to do with the scene name to season number check
// If this needs to be reverted tests will need to be added
if (sceneSeasonNumber.HasValue)
{
var episodes = _episodeService.FindEpisodesBySceneNumbering(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber);

Loading…
Cancel
Save