mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Normalise Line endings (#1284)
* Add .gitattributes * Normalise line endings
This commit is contained in:
@@ -5,7 +5,7 @@ using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jackett.Models
|
||||
@@ -71,33 +71,33 @@ namespace Jackett.Models
|
||||
// Some trackers don't support AND logic for search terms resulting in unwanted results.
|
||||
// Using this method we can AND filter it within jackett.
|
||||
// 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 = null, string queryStringOverride = null)
|
||||
{
|
||||
// We cache the regex split results so we have to do it only once for each query.
|
||||
if (QueryStringParts == null)
|
||||
{
|
||||
var queryString = GetQueryString();
|
||||
if (queryStringOverride != null)
|
||||
queryString = queryStringOverride;
|
||||
if (limit != null && limit > 0)
|
||||
{
|
||||
if (limit > queryString.Length)
|
||||
limit = queryString.Length;
|
||||
queryString = queryString.Substring(0, (int)limit);
|
||||
}
|
||||
Regex SplitRegex = new Regex("[^a-zA-Z0-9]+");
|
||||
QueryStringParts = SplitRegex.Split(queryString);
|
||||
}
|
||||
|
||||
// Check if each part of the query string is in the given title.
|
||||
foreach (var QueryStringPart in QueryStringParts)
|
||||
{
|
||||
if (title.IndexOf(QueryStringPart, StringComparison.OrdinalIgnoreCase) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
public bool MatchQueryStringAND(string title, int? limit = null, string queryStringOverride = null)
|
||||
{
|
||||
// We cache the regex split results so we have to do it only once for each query.
|
||||
if (QueryStringParts == null)
|
||||
{
|
||||
var queryString = GetQueryString();
|
||||
if (queryStringOverride != null)
|
||||
queryString = queryStringOverride;
|
||||
if (limit != null && limit > 0)
|
||||
{
|
||||
if (limit > queryString.Length)
|
||||
limit = queryString.Length;
|
||||
queryString = queryString.Substring(0, (int)limit);
|
||||
}
|
||||
Regex SplitRegex = new Regex("[^a-zA-Z0-9]+");
|
||||
QueryStringParts = SplitRegex.Split(queryString);
|
||||
}
|
||||
|
||||
// Check if each part of the query string is in the given title.
|
||||
foreach (var QueryStringPart in QueryStringParts)
|
||||
{
|
||||
if (title.IndexOf(QueryStringPart, StringComparison.OrdinalIgnoreCase) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public string GetEpisodeSearchString()
|
||||
|
Reference in New Issue
Block a user