mirror of https://github.com/Jackett/Jackett
MatchQueryStringAND: add support for character limit
This commit is contained in:
parent
40dde036d6
commit
8a9949ac93
|
@ -68,13 +68,21 @@ namespace Jackett.Models
|
||||||
|
|
||||||
// Some trackers don't support AND logic for search terms resulting in unwanted results.
|
// Some trackers don't support AND logic for search terms resulting in unwanted results.
|
||||||
// Using this method we can AND filter it within jackett.
|
// Using this method we can AND filter it within jackett.
|
||||||
public bool MatchQueryStringAND(string title)
|
// With limit we can limit the amount of characters which should be compared (use it if a tracker doesn't return the full title).
|
||||||
|
public bool MatchQueryStringAND(string title, int limit = -1)
|
||||||
{
|
{
|
||||||
// We cache the regex split results so we have to do it only once for each query.
|
// We cache the regex split results so we have to do it only once for each query.
|
||||||
if (QueryStringParts == null)
|
if (QueryStringParts == null)
|
||||||
{
|
{
|
||||||
|
var queryString = GetQueryString();
|
||||||
|
if (limit > 0)
|
||||||
|
{
|
||||||
|
if (limit > queryString.Length)
|
||||||
|
limit = queryString.Length;
|
||||||
|
queryString = queryString.Substring(0, limit);
|
||||||
|
}
|
||||||
Regex SplitRegex = new Regex("[^a-zA-Z0-9]+");
|
Regex SplitRegex = new Regex("[^a-zA-Z0-9]+");
|
||||||
QueryStringParts = SplitRegex.Split(GetQueryString());
|
QueryStringParts = SplitRegex.Split(queryString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if each part of the query string is in the given title.
|
// Check if each part of the query string is in the given title.
|
||||||
|
|
Loading…
Reference in New Issue