mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 17:13:49 -07:00
Fixed trakt searching, cleaned up indexer/notification modules
This commit is contained in:
parent
9181b1bb91
commit
f21a235c00
7 changed files with 35 additions and 25 deletions
|
@ -15,8 +15,8 @@ namespace NzbDrone.Common
|
|||
return string.Format(format, formattingArgs.Cast<object>());
|
||||
}
|
||||
|
||||
|
||||
private static readonly Regex InvalidCharRegex = new Regex(@"[^a-z0-9\s-]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex InvalidSearchCharRegex = new Regex(@"[^a-z0-9\s-\.]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex CollapseSpace = new Regex(@"\s+", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public static string ToSlug(this string phrase)
|
||||
|
@ -30,6 +30,18 @@ namespace NzbDrone.Common
|
|||
return phrase;
|
||||
}
|
||||
|
||||
public static string ToSearchTerm(this string phrase)
|
||||
{
|
||||
phrase = phrase.RemoveAccent().ToLower();
|
||||
|
||||
phrase = phrase.Replace("&", "and");
|
||||
phrase = InvalidSearchCharRegex.Replace(phrase, string.Empty);
|
||||
phrase = CollapseSpace.Replace(phrase, " ").Trim();
|
||||
phrase = phrase.Replace(" ", "+");
|
||||
|
||||
return phrase;
|
||||
}
|
||||
|
||||
public static string RemoveAccent(this string txt)
|
||||
{
|
||||
var bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(txt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue