diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs index 2357472ce..cbb616412 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/MapFixture.cs @@ -39,6 +39,7 @@ public void Setup() _parsedEpisodeInfo = new ParsedEpisodeInfo { SeriesTitle = _series.Title, + SeriesTitleInfo = new SeriesTitleInfo(), SeasonNumber = 1, EpisodeNumbers = new[] { 1 } }; @@ -150,6 +151,28 @@ public void should_FindByTitle_when_search_criteria_matching_fails() .Verify(v => v.FindByTitle(It.IsAny()), Times.Once()); } + [Test] + public void should_FindByTitle_using_year_when_FindByTitle_matching_fails() + { + GivenParseResultSeriesDoesntMatchSearchCriteria(); + + _parsedEpisodeInfo.SeriesTitleInfo = new SeriesTitleInfo + { + Title = "Series Title 2017", + TitleWithoutYear = "Series Title", + Year = 2017 + }; + + Mocker.GetMock() + .Setup(s => s.FindByTitle(_parsedEpisodeInfo.SeriesTitleInfo.TitleWithoutYear, _parsedEpisodeInfo.SeriesTitleInfo.Year)) + .Returns(_series); + + Subject.Map(_parsedEpisodeInfo, 10, 10, _singleEpisodeSearchCriteria); + + Mocker.GetMock() + .Verify(v => v.FindByTitle(It.IsAny(), It.IsAny()), Times.Once()); + } + [Test] public void should_FindByTvdbId_when_search_criteria_and_FindByTitle_matching_fails() { diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index 4ab4fd4c7..6d0ee7f6c 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -293,6 +293,11 @@ private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tv series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle); + if (series == null && parsedEpisodeInfo.SeriesTitleInfo.Year > 0) + { + series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitleInfo.TitleWithoutYear, parsedEpisodeInfo.SeriesTitleInfo.Year); + } + if (series == null && tvdbId > 0) { //TODO: If series is found by TvdbId, we should report it as a scene naming exception, since it will fail to import