This commit is contained in:
Garfield69 2020-03-22 12:40:59 +13:00
commit 5978eb7263
1 changed files with 21 additions and 13 deletions

View File

@ -129,13 +129,11 @@ namespace Jackett.Common.Indexers
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{ {
var releases = new List<ReleaseInfo>(); var releases = new List<ReleaseInfo>();
var queryCollection = new NameValueCollection
var searchString = query.GetQueryString(); {
var searchUrl = SearchUrl; {"incldead", "1"},
var queryCollection = new NameValueCollection(); {"rel_type", "0"} // Alle
};
queryCollection.Add("incldead", "1");
queryCollection.Add("rel_type", "0"); // Alle
if (query.ImdbID != null) if (query.ImdbID != null)
{ {
@ -146,20 +144,30 @@ namespace Jackett.Common.Indexers
{ {
queryCollection.Add("searchin", "title"); queryCollection.Add("searchin", "title");
if (!string.IsNullOrWhiteSpace(searchString)) if (!string.IsNullOrWhiteSpace(query.GetQueryString()))
{ {
// use AND+wildcard operator to avoid getting to many useless results // use AND+wildcard operator to avoid getting to many useless results
var searchStringArray = Regex.Split(searchString.Trim(), "[ _.-]+", RegexOptions.Compiled).ToList(); var searchStringArray = Regex.Split(
searchStringArray = searchStringArray.Select(x => "+" + x).ToList(); // add AND operators query.SanitizedSearchTerm, "[ _.-]+",
var searchStringFinal = string.Join(" ", searchStringArray); RegexOptions.Compiled).Select(term => $"+{term}");
queryCollection.Add("search", searchStringFinal);
// If only season search add * wildcard to get all episodes
var tvEpisode = query.GetEpisodeSearchString();
if (!string.IsNullOrWhiteSpace(tvEpisode))
{
if(tvEpisode.StartsWith("S") && !tvEpisode.Contains("E"))
tvEpisode += "*";
searchStringArray = searchStringArray.Append($"+{tvEpisode}");
}
queryCollection.Add("search", string.Join(" ", searchStringArray));
} }
} }
foreach (var cat in MapTorznabCapsToTrackers(query)) foreach (var cat in MapTorznabCapsToTrackers(query))
queryCollection.Add("c" + cat, "1"); queryCollection.Add("c" + cat, "1");
searchUrl += "?" + queryCollection.GetQueryString(); var searchUrl = SearchUrl + "?" + queryCollection.GetQueryString();
var results = await RequestStringWithCookiesAndRetry(searchUrl); var results = await RequestStringWithCookiesAndRetry(searchUrl);