mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 23:42:33 +01:00
Fix: Series Titles with apostrophes when searched on NzbMatrix will now return valid results.
Each indexer can now override GetQueryTitle from IndexerBase if required for special title searching.
This commit is contained in:
parent
2a6f02be17
commit
308fd11c83
@ -270,10 +270,22 @@ namespace NzbDrone.Core.Test
|
|||||||
[TestCase("hawaii five-0 (2010)", "hawaii+five+0+2010")]
|
[TestCase("hawaii five-0 (2010)", "hawaii+five+0+2010")]
|
||||||
[TestCase("this& that", "this+that")]
|
[TestCase("this& that", "this+that")]
|
||||||
[TestCase("this& that", "this+that")]
|
[TestCase("this& that", "this+that")]
|
||||||
|
[TestCase("grey's anatomy", "grey+s+anatomy")]
|
||||||
public void get_query_title(string raw, string clean)
|
public void get_query_title(string raw, string clean)
|
||||||
{
|
{
|
||||||
var result = IndexerBase.GetQueryTitle(raw);
|
var mock = new Mock<IndexerBase>();
|
||||||
|
mock.CallBase = true;
|
||||||
|
var result = mock.Object.GetQueryTitle(raw);
|
||||||
|
result.Should().Be(clean);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("hawaii five-0 (2010)", "hawaii+five+0+2010")]
|
||||||
|
[TestCase("this& that", "this+that")]
|
||||||
|
[TestCase("this& that", "this+that")]
|
||||||
|
[TestCase("grey's anatomy", "greys+anatomy")]
|
||||||
|
public void get_query_title_nzbmatrix_should_replace_apostrophe_with_empty_string(string raw, string clean)
|
||||||
|
{
|
||||||
|
var result = Mocker.Resolve<NzbMatrix>().GetQueryTitle(raw);
|
||||||
result.Should().Be(clean);
|
result.Should().Be(clean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,12 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
return CustomParser(item, episodeParseResult);
|
return CustomParser(item, episodeParseResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetQueryTitle(string title)
|
/// <summary>
|
||||||
|
/// This method can be overwritten to provide indexer specific title cleaning
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title">Title that needs to be cleaned</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual string GetQueryTitle(string title)
|
||||||
{
|
{
|
||||||
var cleanTitle = TitleSearchRegex.Replace(title, "+").Trim('+', ' ');
|
var cleanTitle = TitleSearchRegex.Replace(title, "+").Trim('+', ' ');
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Regex TitleSearchRegex = new Regex(@"[\W]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
|
||||||
protected override string[] Urls
|
protected override string[] Urls
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -94,7 +96,6 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
get { return "NzbMatrix"; }
|
get { return "NzbMatrix"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override string NzbDownloadUrl(SyndicationItem item)
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
||||||
{
|
{
|
||||||
return item.Links[0].Uri.ToString();
|
return item.Links[0].Uri.ToString();
|
||||||
@ -110,5 +111,16 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
}
|
}
|
||||||
return currentResult;
|
return currentResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string GetQueryTitle(string title)
|
||||||
|
{
|
||||||
|
//Replace apostrophe with empty string
|
||||||
|
title = title.Replace("'", "");
|
||||||
|
var cleanTitle = TitleSearchRegex.Replace(title, "+").Trim('+', ' ');
|
||||||
|
|
||||||
|
//remove any repeating +s
|
||||||
|
cleanTitle = Regex.Replace(cleanTitle, @"\+{1,100}", "+");
|
||||||
|
return cleanTitle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user