From 2303a02a061581eae88c4abe1c74e7dd4cea6d72 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 26 Feb 2012 21:33:24 -0800 Subject: [PATCH] Fixed: Fixed issue where NzbMatrix servers would die if series title started with 'the' --- NzbDrone.Core.Test/IndexerTests.cs | 12 +++++++----- NzbDrone.Core/Providers/Indexer/IndexerBase.cs | 3 +++ NzbDrone.Core/Providers/Indexer/NzbMatrix.cs | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 0d93fb8d5..fab01260a 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -237,15 +237,16 @@ namespace NzbDrone.Core.Test result.Should().NotBeEmpty(); } - [Test] - public void nzbmatrix_search_returns_valid_results() + [TestCase("simpsons", 21, 23)] + [TestCase("The walking dead", 2, 10)] + public void nzbmatrix_search_returns_valid_results(string title, int season, int episode) { WithConfiguredIndexers(); Mocker.Resolve(); - var result = Mocker.Resolve().FetchEpisode("Simpsons", 21, 23); + var result = Mocker.Resolve().FetchEpisode(title, season, episode); Mark500Inconclusive(); @@ -253,6 +254,7 @@ namespace NzbDrone.Core.Test } + [Test] public void nzbmatrix_multi_word_search_returns_valid_results() { @@ -275,7 +277,7 @@ namespace NzbDrone.Core.Test public void get_query_title(string raw, string clean) { var mock = new Mock(); - mock.CallBase = true; + mock.CallBase = true; var result = mock.Object.GetQueryTitle(raw); result.Should().Be(clean); } @@ -387,7 +389,7 @@ namespace NzbDrone.Core.Test public void indexer_that_isnt_configured_shouldnt_make_an_http_call() { Mocker.Resolve().FetchRss(); - + Mocker.GetMock() .Verify(c => c.DownloadFile(It.IsAny(), It.IsAny()), Times.Never()); diff --git a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs index 157bb2cc4..31aaff3ad 100644 --- a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs +++ b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs @@ -19,6 +19,7 @@ namespace NzbDrone.Core.Providers.Indexer protected readonly ConfigProvider _configProvider; private static readonly Regex TitleSearchRegex = new Regex(@"[\W]", RegexOptions.IgnoreCase | RegexOptions.Compiled); + protected static readonly Regex RemoveThe = new Regex(@"^the\s", RegexOptions.IgnoreCase | RegexOptions.Compiled); [Inject] protected IndexerBase(HttpProvider httpProvider, ConfigProvider configProvider) @@ -230,6 +231,8 @@ namespace NzbDrone.Core.Providers.Indexer /// public virtual string GetQueryTitle(string title) { + title = RemoveThe.Replace(title, string.Empty); + var cleanTitle = TitleSearchRegex.Replace(title, "+").Trim('+', ' '); //remove any repeating +s diff --git a/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs b/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs index 12edbf8df..3aa45e0be 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs @@ -116,6 +116,7 @@ namespace NzbDrone.Core.Providers.Indexer { //Replace apostrophe with empty string title = title.Replace("'", ""); + title = RemoveThe.Replace(title, string.Empty); var cleanTitle = TitleSearchRegex.Replace(title, "+").Trim('+', ' '); //remove any repeating +s