Fixed: Fixed issue where NzbMatrix servers would die if series title started with 'the'

This commit is contained in:
kay.one 2012-02-26 21:33:24 -08:00
parent 24dae1927f
commit 2303a02a06
3 changed files with 11 additions and 5 deletions

View File

@ -237,15 +237,16 @@ namespace NzbDrone.Core.Test
result.Should().NotBeEmpty(); result.Should().NotBeEmpty();
} }
[Test] [TestCase("simpsons", 21, 23)]
public void nzbmatrix_search_returns_valid_results() [TestCase("The walking dead", 2, 10)]
public void nzbmatrix_search_returns_valid_results(string title, int season, int episode)
{ {
WithConfiguredIndexers(); WithConfiguredIndexers();
Mocker.Resolve<HttpProvider>(); Mocker.Resolve<HttpProvider>();
var result = Mocker.Resolve<NzbMatrix>().FetchEpisode("Simpsons", 21, 23); var result = Mocker.Resolve<NzbMatrix>().FetchEpisode(title, season, episode);
Mark500Inconclusive(); Mark500Inconclusive();
@ -253,6 +254,7 @@ namespace NzbDrone.Core.Test
} }
[Test] [Test]
public void nzbmatrix_multi_word_search_returns_valid_results() public void nzbmatrix_multi_word_search_returns_valid_results()
{ {

View File

@ -19,6 +19,7 @@ namespace NzbDrone.Core.Providers.Indexer
protected readonly ConfigProvider _configProvider; protected readonly ConfigProvider _configProvider;
private static readonly Regex TitleSearchRegex = new Regex(@"[\W]", RegexOptions.IgnoreCase | RegexOptions.Compiled); 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] [Inject]
protected IndexerBase(HttpProvider httpProvider, ConfigProvider configProvider) protected IndexerBase(HttpProvider httpProvider, ConfigProvider configProvider)
@ -230,6 +231,8 @@ namespace NzbDrone.Core.Providers.Indexer
/// <returns></returns> /// <returns></returns>
public virtual string GetQueryTitle(string title) public virtual string GetQueryTitle(string title)
{ {
title = RemoveThe.Replace(title, string.Empty);
var cleanTitle = TitleSearchRegex.Replace(title, "+").Trim('+', ' '); var cleanTitle = TitleSearchRegex.Replace(title, "+").Trim('+', ' ');
//remove any repeating +s //remove any repeating +s

View File

@ -116,6 +116,7 @@ namespace NzbDrone.Core.Providers.Indexer
{ {
//Replace apostrophe with empty string //Replace apostrophe with empty string
title = title.Replace("'", ""); title = title.Replace("'", "");
title = RemoveThe.Replace(title, string.Empty);
var cleanTitle = TitleSearchRegex.Replace(title, "+").Trim('+', ' '); var cleanTitle = TitleSearchRegex.Replace(title, "+").Trim('+', ' ');
//remove any repeating +s //remove any repeating +s