Fixed: Parsing episodes when full series does not have XEM mappings
Fixed #4849
This commit is contained in:
parent
853f4d1e29
commit
a36397452d
|
@ -77,6 +77,12 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
|
|||
_parsedEpisodeInfo.AbsoluteEpisodeNumbers = new[] { 1 };
|
||||
}
|
||||
|
||||
private void GivenFullSeason()
|
||||
{
|
||||
_parsedEpisodeInfo.FullSeason = true;
|
||||
_parsedEpisodeInfo.EpisodeNumbers = Array.Empty<int>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_daily_episode_episode_when_search_criteria_is_null()
|
||||
{
|
||||
|
@ -452,5 +458,65 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
|
|||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisode(_series.Id, _parsedEpisodeInfo.SeasonNumber, _parsedEpisodeInfo.EpisodeNumbers.First()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_lookup_full_season_by_season_number_if_series_does_not_use_scene_numbering()
|
||||
{
|
||||
GivenFullSeason();
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(s => s.GetEpisodesBySeason(_series.Id, _parsedEpisodeInfo.SeasonNumber))
|
||||
.Returns(_episodes);
|
||||
|
||||
Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.GetEpisodesBySeason(It.IsAny<int>(), It.IsAny<int>()), Times.Once);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.GetEpisodesBySceneSeason(It.IsAny<int>(), It.IsAny<int>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_lookup_full_season_by_scene_season_number_if_series_uses_scene_numbering()
|
||||
{
|
||||
GivenSceneNumberingSeries();
|
||||
GivenFullSeason();
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(s => s.GetEpisodesBySceneSeason(_series.Id, _parsedEpisodeInfo.SeasonNumber))
|
||||
.Returns(_episodes);
|
||||
|
||||
Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.GetEpisodesBySeason(It.IsAny<int>(), It.IsAny<int>()), Times.Never);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.GetEpisodesBySceneSeason(It.IsAny<int>(), It.IsAny<int>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_fallback_to_lookup_full_season_by_season_number_if_series_uses_scene_numbering_and_no_epsiodes_are_found_by_scene_season_number()
|
||||
{
|
||||
GivenSceneNumberingSeries();
|
||||
GivenFullSeason();
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(s => s.GetEpisodesBySceneSeason(_series.Id, _parsedEpisodeInfo.SeasonNumber))
|
||||
.Returns(new List<Episode>());
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(s => s.GetEpisodesBySeason(_series.Id, _parsedEpisodeInfo.SeasonNumber))
|
||||
.Returns(_episodes);
|
||||
|
||||
Subject.GetEpisodes(_parsedEpisodeInfo, _series, true, null);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.GetEpisodesBySeason(It.IsAny<int>(), It.IsAny<int>()), Times.Once);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.GetEpisodesBySceneSeason(It.IsAny<int>(), It.IsAny<int>()), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,12 +209,16 @@ namespace NzbDrone.Core.Parser
|
|||
{
|
||||
if (series.UseSceneNumbering && sceneSource)
|
||||
{
|
||||
return _episodeService.GetEpisodesBySceneSeason(series.Id, mappedSeasonNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _episodeService.GetEpisodesBySeason(series.Id, mappedSeasonNumber);
|
||||
var episodes = _episodeService.GetEpisodesBySceneSeason(series.Id, mappedSeasonNumber);
|
||||
|
||||
// If episodes were found by the scene season number return them, otherwise fallback to look-up by season number
|
||||
if (episodes.Any())
|
||||
{
|
||||
return episodes;
|
||||
}
|
||||
}
|
||||
|
||||
return _episodeService.GetEpisodesBySeason(series.Id, mappedSeasonNumber);
|
||||
}
|
||||
|
||||
if (parsedEpisodeInfo.IsDaily)
|
||||
|
|
Loading…
Reference in New Issue