mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-20 22:14:34 -04:00
Fixed: Standardize dashes/single quotes in search term, ignore artist if "VA"
This commit is contained in:
@@ -7,9 +7,8 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
||||
{
|
||||
public abstract class SearchCriteriaBase
|
||||
{
|
||||
private static readonly Regex SpecialCharacter = new Regex(@"[`'.]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
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);
|
||||
private static readonly Regex StandardizeDashesRegex = new (@"\p{Pd}+", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
private static readonly Regex StandardizeSingleQuotesRegex = new (@"[\u0060\u00B4\u2018\u2019]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
public virtual bool InteractiveSearch { get; set; }
|
||||
public List<int> IndexerIds { get; set; }
|
||||
@@ -21,58 +20,24 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
||||
public string Source { get; set; }
|
||||
public string Host { get; set; }
|
||||
|
||||
public virtual string SearchQuery
|
||||
public override string ToString() => $"{SearchQuery}, Offset: {Offset ?? 0}, Limit: {Limit ?? 0}, Categories: [{string.Join(", ", Categories)}]";
|
||||
|
||||
public virtual string SearchQuery => $"Term: [{SearchTerm}]";
|
||||
|
||||
public virtual bool RssSearch => SearchTerm.IsNullOrWhiteSpace();
|
||||
|
||||
public string SanitizedSearchTerm => GetSanitizedTerm(SearchTerm);
|
||||
|
||||
private static string GetSanitizedTerm(string term)
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"Term: [{SearchTerm}]";
|
||||
}
|
||||
}
|
||||
term ??= "";
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{SearchQuery}, Offset: {Offset ?? 0}, Limit: {Limit ?? 0}, Categories: [{string.Join(", ", Categories)}]";
|
||||
}
|
||||
term = StandardizeDashesRegex.Replace(term, "-");
|
||||
term = StandardizeSingleQuotesRegex.Replace(term, "'");
|
||||
|
||||
public virtual bool RssSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SearchTerm.IsNullOrWhiteSpace())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
var safeTitle = term.Where(c => char.IsLetterOrDigit(c) || char.IsWhiteSpace(c) || c is '-' or '.' or '_' or '(' or ')' or '@' or '/' or '\'' or '[' or ']' or '+' or '%');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string SanitizedSearchTerm
|
||||
{
|
||||
get
|
||||
{
|
||||
var term = SearchTerm;
|
||||
if (SearchTerm == null)
|
||||
{
|
||||
term = "";
|
||||
}
|
||||
|
||||
var safeTitle = term.Where(c => (char.IsLetterOrDigit(c)
|
||||
|| char.IsWhiteSpace(c)
|
||||
|| c == '-'
|
||||
|| c == '.'
|
||||
|| c == '_'
|
||||
|| c == '('
|
||||
|| c == ')'
|
||||
|| c == '@'
|
||||
|| c == '/'
|
||||
|| c == '\''
|
||||
|| c == '['
|
||||
|| c == ']'
|
||||
|| c == '+'
|
||||
|| c == '%'));
|
||||
return string.Concat(safeTitle);
|
||||
}
|
||||
return string.Concat(safeTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user