mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-17 15:02:34 +02:00
New: Import Existing series now handles camelCase titles without spaces.
This commit is contained in:
parent
17ac82385a
commit
6dc72713be
@ -37,6 +37,14 @@ public void Setup()
|
||||
[TestCase("tvdb:78804", "Doctor Who (2005)")]
|
||||
[TestCase("TVDB:78804", "Doctor Who (2005)")]
|
||||
[TestCase("TVDB: 78804 ", "Doctor Who (2005)")]
|
||||
[TestCase("TheBigBangTheory", "The Big Bang Theory")]
|
||||
[TestCase("Agents of S.H.I.E.L.D.", "Marvel's Agents of S.H.I.E.L.D.")]
|
||||
[TestCase("Marvel's Agents of S.H.I.E.L.D.", "Marvel's Agents of S.H.I.E.L.D.")]
|
||||
[TestCase("Marvel'sAgentsOfS.H.I.E.L.D.", "Marvel's Agents of S.H.I.E.L.D.")]
|
||||
[TestCase("Utopia (US) (2014)", "Utopia (US) (2014)")]
|
||||
[TestCase("Utopia US 2014", "Utopia (US) (2014)")]
|
||||
[TestCase("UtopiaUS2014", "Utopia (US) (2014)")]
|
||||
[TestCase("@Midnight", "@midnight")]
|
||||
public void successful_search(string title, string expected)
|
||||
{
|
||||
var result = Subject.SearchForNewSeries(title);
|
||||
|
@ -19,8 +19,8 @@ public class TraktProxy : ISearchForNewSeries, IProvideSeriesInfo
|
||||
private readonly IHttpClient _httpClient;
|
||||
private static readonly Regex CollapseSpaceRegex = new Regex(@"\s+", RegexOptions.Compiled);
|
||||
private static readonly Regex InvalidSearchCharRegex = new Regex(@"(?:\*|\(|\)|'|!|@|\+)", RegexOptions.Compiled);
|
||||
|
||||
|
||||
private static readonly Regex ExpandCamelCaseRegEx = new Regex(@"(?<!^|[A-Z]\.?|[^\w.])(?=[A-Z])", RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);
|
||||
|
||||
private readonly HttpRequestBuilder _requestBuilder;
|
||||
|
||||
public TraktProxy(Logger logger, IHttpClient httpClient)
|
||||
@ -230,12 +230,13 @@ private static string FromIsoToString(string iso)
|
||||
}
|
||||
|
||||
private static string GetSearchTerm(string phrase)
|
||||
{
|
||||
phrase = phrase.RemoveAccent().ToLower();
|
||||
{
|
||||
phrase = phrase.RemoveAccent();
|
||||
phrase = InvalidSearchCharRegex.Replace(phrase, "");
|
||||
phrase = CollapseSpaceRegex.Replace(phrase, " ").Trim().ToLower();
|
||||
phrase = ExpandCamelCaseRegEx.Replace(phrase, " ");
|
||||
phrase = CollapseSpaceRegex.Replace(phrase, " ").Trim();
|
||||
phrase = phrase.Trim('-');
|
||||
phrase = System.Web.HttpUtility.UrlEncode(phrase);
|
||||
phrase = System.Web.HttpUtility.UrlEncode(phrase.ToLower());
|
||||
|
||||
return phrase;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user