diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs index d8c6fbb8d..e0277d3e4 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs @@ -220,5 +220,45 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests Mocker.GetMock() .Verify(v => v.FindByTitle(It.IsAny()), Times.Never()); } + + [Test] + public void should_use_scene_season_number_from_xem_mapping_if_alias_matches_a_specific_season_number() + { + _parsedEpisodeInfo.SeasonNumber = 1; + + var sceneMapping = new SceneMapping + { + Type = "XemService", + SceneSeasonNumber = 2 + }; + + Mocker.GetMock() + .Setup(s => s.FindSceneMapping(_parsedEpisodeInfo.SeriesTitle, _parsedEpisodeInfo.ReleaseTitle, _parsedEpisodeInfo.SeasonNumber)) + .Returns(sceneMapping); + + var result = Subject.Map(_parsedEpisodeInfo, _series); + + result.MappedSeasonNumber.Should().Be(sceneMapping.SceneSeasonNumber); + } + + [Test] + public void should_not_use_scene_season_number_from_xem_mapping_if_alias_matches_a_specific_season_number_but_did_not_parse_season_1() + { + _parsedEpisodeInfo.SeasonNumber = 2; + + var sceneMapping = new SceneMapping + { + Type = "XemService", + SceneSeasonNumber = 2 + }; + + Mocker.GetMock() + .Setup(s => s.FindSceneMapping(_parsedEpisodeInfo.SeriesTitle, _parsedEpisodeInfo.ReleaseTitle, _parsedEpisodeInfo.SeasonNumber)) + .Returns(sceneMapping); + + var result = Subject.Map(_parsedEpisodeInfo, _series); + + result.MappedSeasonNumber.Should().Be(sceneMapping.SceneSeasonNumber); + } } } diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index afa8ef115..118fda239 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -163,6 +163,13 @@ namespace NzbDrone.Core.Parser { sceneSource = false; } + else if (sceneMapping.Type == "XemService" && + sceneMapping.SceneSeasonNumber.HasValue && + parsedEpisodeInfo.SeasonNumber == 1 && + sceneMapping.SceneSeasonNumber != parsedEpisodeInfo.SeasonNumber) + { + remoteEpisode.MappedSeasonNumber = sceneMapping.SceneSeasonNumber.Value; + } } if (series == null)