From 9107d1678c5f2799b655262dbb100a8f1ab6cde5 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Mon, 21 Jan 2019 21:11:55 +0100 Subject: [PATCH] Fixed: Failure to match S12E00 special due to episode file vs folder being parsed differently. --- .../MatchesFolderSpecificationFixture.cs | 32 +++++++++++++++++++ .../MatchesFolderSpecification.cs | 5 +++ 2 files changed, 37 insertions(+) diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs index cab1754dd..9b299aa89 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs @@ -1,7 +1,9 @@ using FizzWare.NBuilder; using FluentAssertions; +using Moq; using NUnit.Framework; using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; +using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -131,5 +133,35 @@ public void should_be_rejected_if_file_and_folder_do_not_have_episodes_from_the_ Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeFalse(); } + + [Test] + public void should_be_accepted_if_both_file_and_folder_info_map_to_same_special() + { + var title = "Some.Special.S12E00.WEB-DL.1080p-GoodNightTV"; + var actualInfo = Parser.Parser.ParseTitle("Some.Special.S0E100.WEB-DL.1080p-GoodNightTV.mkv"); + + var folderInfo = Parser.Parser.ParseTitle(title); + var fileInfo = Parser.Parser.ParseTitle(title + ".mkv"); + var localEpisode = new LocalEpisode + { + FileEpisodeInfo = fileInfo, + FolderEpisodeInfo = folderInfo, + Series = new Tv.Series + { + Id = 1, + Title = "Some Special" + } + }; + + Mocker.GetMock() + .Setup(v => v.ParseSpecialEpisodeTitle(fileInfo, It.IsAny(), 0, 0, null)) + .Returns(actualInfo); + + Mocker.GetMock() + .Setup(v => v.ParseSpecialEpisodeTitle(folderInfo, It.IsAny(), 0, 0, null)) + .Returns(actualInfo); + + Subject.IsSatisfiedBy(localEpisode, null).Accepted.Should().BeTrue(); + } } } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs index 8c85ad958..199fe31fa 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs @@ -27,6 +27,11 @@ public Decision IsSatisfiedBy(LocalEpisode localEpisode, DownloadClientItem down var fileInfo = localEpisode.FileEpisodeInfo; var folderInfo = localEpisode.FolderEpisodeInfo; + if (fileInfo != null && fileInfo.IsPossibleSceneSeasonSpecial) + { + fileInfo = _parsingService.ParseSpecialEpisodeTitle(fileInfo, fileInfo.ReleaseTitle, localEpisode.Series.TvdbId, 0); + } + if (folderInfo != null && folderInfo.IsPossibleSceneSeasonSpecial) { folderInfo = _parsingService.ParseSpecialEpisodeTitle(folderInfo, folderInfo.ReleaseTitle, localEpisode.Series.TvdbId, 0);