Fixed: Search fails for many artist and albums with specials (#466)

* Fixed: Search fails for many artist/albums with specials

* fixup! Replace & with space

* fixup! Add two more test cases

* fixup! Add last test case

* fixup: Newznab test case
This commit is contained in:
Qstick
2018-09-04 22:55:08 -04:00
committed by GitHub
parent 23bc5b11cf
commit 812af82fae
10 changed files with 51 additions and 36 deletions
@@ -13,9 +13,6 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
private static readonly Regex NonWord = new Regex(@"[\W]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex BeginningThe = new Regex(@"^the\s", RegexOptions.IgnoreCase | RegexOptions.Compiled);
[System.Obsolete("Sonarr TV Stuff -- Shouldn't be needed for Lidarr")]
public List<string> SceneTitles { get; set; }
public virtual bool MonitoredEpisodesOnly { get; set; }
public virtual bool UserInvokedSearch { get; set; }
public virtual bool InteractiveSearch { get; set; }
@@ -24,7 +21,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
public List<Album> Albums { get; set; }
public List<Track> Tracks { get; set; }
public List<string> QueryTitles => SceneTitles.Select(GetQueryTitle).ToList();
public string ArtistQuery => GetQueryTitle(Artist.Name);
public static string GetQueryTitle(string title)
{
@@ -32,14 +29,16 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
var cleanTitle = BeginningThe.Replace(title, string.Empty);
cleanTitle = cleanTitle.Replace("&", "and");
cleanTitle = cleanTitle.Replace(" & ", " ");
cleanTitle = SpecialCharacter.Replace(cleanTitle, "");
cleanTitle = NonWord.Replace(cleanTitle, "+");
//remove any repeating +s
cleanTitle = Regex.Replace(cleanTitle, @"\+{2,}", "+");
cleanTitle = cleanTitle.RemoveAccent();
return cleanTitle.Trim('+', ' ');
cleanTitle = cleanTitle.Trim('+', ' ');
return cleanTitle.Length == 0 ? title : cleanTitle;
}
}
}