mirror of https://github.com/Jackett/Jackett
Norbits: duplicate search without diacritics
This commit is contained in:
parent
34cdedae12
commit
a34a3fb4b6
|
@ -226,14 +226,14 @@ namespace Jackett.Indexers
|
||||||
{
|
{
|
||||||
var releases = new List<ReleaseInfo>();
|
var releases = new List<ReleaseInfo>();
|
||||||
var torrentRowList = new List<CQ>();
|
var torrentRowList = new List<CQ>();
|
||||||
var searchTerm = query.GetQueryString();
|
var exactSearchTerm = query.GetQueryString();
|
||||||
var searchUrl = SearchUrl;
|
var searchUrl = SearchUrl;
|
||||||
|
|
||||||
// Check login before performing a query
|
// Check login before performing a query
|
||||||
await CheckLogin();
|
await CheckLogin();
|
||||||
|
|
||||||
// Check cache first so we don't query the server (if search term used or not in dev mode)
|
// Check cache first so we don't query the server (if search term used or not in dev mode)
|
||||||
if (!DevMode && !string.IsNullOrEmpty(searchTerm))
|
if (!DevMode && !string.IsNullOrEmpty(exactSearchTerm))
|
||||||
{
|
{
|
||||||
lock (cache)
|
lock (cache)
|
||||||
{
|
{
|
||||||
|
@ -241,12 +241,21 @@ namespace Jackett.Indexers
|
||||||
CleanCache();
|
CleanCache();
|
||||||
|
|
||||||
// Search in cache
|
// Search in cache
|
||||||
var cachedResult = cache.FirstOrDefault(i => i.Query == searchTerm);
|
var cachedResult = cache.FirstOrDefault(i => i.Query == exactSearchTerm);
|
||||||
if (cachedResult != null)
|
if (cachedResult != null)
|
||||||
return cachedResult.Results.Select(s => (ReleaseInfo)s.Clone()).ToArray();
|
return cachedResult.Results.Select(s => (ReleaseInfo)s.Clone()).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var SearchTerms = new List<string> { exactSearchTerm };
|
||||||
|
|
||||||
|
// duplicate search without diacritics
|
||||||
|
var baseSearchTerm = StringUtil.RemoveDiacritics(exactSearchTerm);
|
||||||
|
if (baseSearchTerm != exactSearchTerm)
|
||||||
|
SearchTerms.Add(baseSearchTerm);
|
||||||
|
|
||||||
|
foreach (var searchTerm in SearchTerms)
|
||||||
|
{
|
||||||
// Build our query
|
// Build our query
|
||||||
var request = BuildQuery(searchTerm, query, searchUrl);
|
var request = BuildQuery(searchTerm, query, searchUrl);
|
||||||
|
|
||||||
|
@ -282,7 +291,7 @@ namespace Jackett.Indexers
|
||||||
Output("\nNo result found for your query, please try another search term ...\n", "info");
|
Output("\nNo result found for your query, please try another search term ...\n", "info");
|
||||||
|
|
||||||
// No result found for this query
|
// No result found for this query
|
||||||
return releases;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,7 +429,7 @@ namespace Jackett.Indexers
|
||||||
{
|
{
|
||||||
OnParseError("Error, unable to parse result \n" + ex.StackTrace, ex);
|
OnParseError("Error, unable to parse result \n" + ex.StackTrace, ex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Return found releases
|
// Return found releases
|
||||||
return releases;
|
return releases;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using AngleSharp.Html;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
@ -28,6 +29,22 @@ namespace Jackett.Utils
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replaces culture specific characters with the corresponding base characters (e.g. è becomes e).
|
||||||
|
public static String RemoveDiacritics(String s)
|
||||||
|
{
|
||||||
|
String normalizedString = s.Normalize(NormalizationForm.FormD);
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < normalizedString.Length; i++)
|
||||||
|
{
|
||||||
|
Char c = normalizedString[i];
|
||||||
|
if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)
|
||||||
|
stringBuilder.Append(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
public static string FromBase64(string str)
|
public static string FromBase64(string str)
|
||||||
{
|
{
|
||||||
return Encoding.UTF8.GetString(Convert.FromBase64String(str));
|
return Encoding.UTF8.GetString(Convert.FromBase64String(str));
|
||||||
|
|
Loading…
Reference in New Issue