ParseSeriesName will now return normalized version of the title if it doesn't match any predefined

PostDownload provider will skip subfolders that are known series folders.
pull/3113/head
kay.one 13 years ago
parent f5a8c3de87
commit e269494ff8

@ -115,7 +115,7 @@
<Compile Include="ProviderTests\DiskProviderTests\ExtractArchiveFixture.cs" />
<Compile Include="ProviderTests\PostDownloadProviderTests\PostDownloadProviderFixture.cs" />
<Compile Include="JobTests\SearchJobTest.cs" />
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDownloadFixture.cs" />
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDownloadProviderFixture.cs" />
<Compile Include="ProviderTests\JobProviderTests\TestJobs.cs" />
<Compile Include="JobTests\AppUpdateJobFixture.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\GetUpdateLogFixture.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);

@ -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<string>
{
@"c:\drop\episode1",
@"c:\drop\episode2",
@"c:\drop\episode3",
@"c:\drop\episode4"
};
Mocker.GetMock<DiskProvider>()
.Setup(c => c.GetDirectories(It.IsAny<String>()))
.Returns(subFolders);
Mocker.GetMock<SeriesProvider>()
.Setup(c => c.SeriesPathExists(subFolders[1]))
.Returns(true);
Mocker.GetMock<SeriesProvider>()
.Setup(c => c.FindSeries(It.IsAny<String>()))
.Returns(new Series());
Mocker.GetMock<DiskScanProvider>()
.Setup(c => c.Scan(It.IsAny<Series>(), It.IsAny<String>()))
.Returns(new List<EpisodeFile>());
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDropFolder(@"C:\drop\");
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(It.IsAny<Series>(), subFolders[0]), Times.Once());
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(It.IsAny<Series>(), subFolders[1]), Times.Never());
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(It.IsAny<Series>(), subFolders[2]), Times.Once());
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(It.IsAny<Series>(), subFolders[3]), Times.Once());
}
}
}

@ -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;
}
/// <summary>
/// Parses a post title to find the series that relates to it
/// </summary>
/// <param name = "title">Title of the report</param>
/// <returns>Normalized Series Name</returns>
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)

@ -36,7 +36,10 @@ namespace NzbDrone.Core.Providers
{
try
{
ProcessDownload(new DirectoryInfo(subfolder));
if (!_seriesProvider.SeriesPathExists(subfolder))
{
ProcessDownload(new DirectoryInfo(subfolder));
}
}
catch (Exception e)
{

@ -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<Series> SearchForSeries(string title)

Loading…
Cancel
Save