diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 5d3ccc7e0..db25df83f 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -115,7 +115,7 @@ - + diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 01f1f975a..30023363d 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -288,9 +288,10 @@ namespace NzbDrone.Core.Test [TestCase("Chuck - 4x05 - Title", "Chuck")] [TestCase("Law & Order - 4x05 - Title", "laworder")] - [TestCase("This Isn't a Valid Post", "")] + [TestCase("Bad Format", "badformat")] [TestCase("Mad Men - Season 1 [Bluray720p]", "madmen")] [TestCase("Mad Men - Season 1 [Bluray1080p]", "madmen")] + [TestCase("The Daily Show With Jon Stewart -", "dailyshowwithjonstewart")] public void parse_series_name(string postTitle, string title) { var result = Parser.ParseSeriesName(postTitle); diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadProviderFixture.cs similarity index 85% rename from NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs rename to NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadProviderFixture.cs index be684a5ea..f39e5e7ba 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadProviderFixture.cs @@ -10,7 +10,6 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -19,7 +18,7 @@ using NzbDrone.Test.Common.AutoMoq; namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests { [TestFixture] - public class ProcessDownloadFixture : CoreTest + public class ProcessDownloadProviderFixture : CoreTest { [Test] public void should_skip_if_folder_is_tagged_and_too_fresh() @@ -245,5 +244,44 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests Times.Exactly(fakeEpisodeFiles.Count)); mocker.VerifyAllMocks(); } + + + [Test] + public void ProcessDropFolder_should_only_process_folders_that_arent_known_series_folders() + { + var subFolders = new List + { + @"c:\drop\episode1", + @"c:\drop\episode2", + @"c:\drop\episode3", + @"c:\drop\episode4" + }; + + Mocker.GetMock() + .Setup(c => c.GetDirectories(It.IsAny())) + .Returns(subFolders); + + Mocker.GetMock() + .Setup(c => c.SeriesPathExists(subFolders[1])) + .Returns(true); + + Mocker.GetMock() + .Setup(c => c.FindSeries(It.IsAny())) + .Returns(new Series()); + + Mocker.GetMock() + .Setup(c => c.Scan(It.IsAny(), It.IsAny())) + .Returns(new List()); + + //Act + Mocker.Resolve().ProcessDropFolder(@"C:\drop\"); + + + //Assert + Mocker.GetMock().Verify(c => c.Scan(It.IsAny(), subFolders[0]), Times.Once()); + Mocker.GetMock().Verify(c => c.Scan(It.IsAny(), subFolders[1]), Times.Never()); + Mocker.GetMock().Verify(c => c.Scan(It.IsAny(), subFolders[2]), Times.Once()); + Mocker.GetMock().Verify(c => c.Scan(It.IsAny(), subFolders[3]), Times.Once()); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index a729b4255..5d2b19ff0 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -96,7 +96,7 @@ namespace NzbDrone.Core { //Check if episode is in the future (most likley a parse error) if (result.AirDate > DateTime.Now.AddDays(1).Date) - break; + break; result.Language = ParseLanguage(title); result.Quality = ParseQuality(title); @@ -185,12 +185,7 @@ namespace NzbDrone.Core return parsedEpisode; } - /// - /// Parses a post title to find the series that relates to it - /// - /// Title of the report - /// Normalized Series Name - internal static string ParseSeriesName(string title) + public static string ParseSeriesName(string title) { Logger.Trace("Parsing string '{0}'", title); @@ -207,7 +202,7 @@ namespace NzbDrone.Core } } - return String.Empty; + return NormalizeTitle(title); } internal static Quality ParseQuality(string name) diff --git a/NzbDrone.Core/Providers/PostDownloadProvider.cs b/NzbDrone.Core/Providers/PostDownloadProvider.cs index 62647333e..be1a7bf2a 100644 --- a/NzbDrone.Core/Providers/PostDownloadProvider.cs +++ b/NzbDrone.Core/Providers/PostDownloadProvider.cs @@ -36,7 +36,10 @@ namespace NzbDrone.Core.Providers { try { - ProcessDownload(new DirectoryInfo(subfolder)); + if (!_seriesProvider.SeriesPathExists(subfolder)) + { + ProcessDownload(new DirectoryInfo(subfolder)); + } } catch (Exception e) { diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index 82e2e4ead..5c2242b14 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using NLog; +using NzbDrone.Common; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; using NzbDrone.Core.Repository.Quality; @@ -176,12 +177,11 @@ namespace NzbDrone.Core.Providers } } - public virtual bool SeriesPathExists(string cleanPath) + public virtual bool SeriesPathExists(string path) { - if (GetAllSeries().Any(s => s.Path.ToLower() == cleanPath.ToLower())) - return true; + var normilizedPath = path.NormalizePath(); - return false; + return GetAllSeries().Any(s => s.Path.NormalizePath() == normilizedPath); } public virtual List SearchForSeries(string title)