Skip to content

Commit

Permalink
cardigann: fix search paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Jun 24, 2023
1 parent b6398bf commit 5ebe1de
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/Jackett.Common/Indexers/CardigannIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1414,26 +1414,27 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
var SearchPaths = Search.Paths;
foreach (var SearchPath in SearchPaths)
{
variables[".Categories"] = mappedCategories;
var localMappedCategories = mappedCategories;
variables[".Categories"] = localMappedCategories;

// skip path if categories don't match
if (SearchPath.Categories.Count > 0)
{
var hasIntersect = mappedCategories.Intersect(SearchPath.Categories).Any();

if (SearchPath.Categories[0] == "!")
if (localMappedCategories.Count == 0)
{
hasIntersect = !hasIntersect;
localMappedCategories = GetAllTrackerCategories();
}

if (!hasIntersect)
{
variables[".Categories"] = mappedCategories.Except(SearchPath.Categories).ToList();
var categories = SearchPath.Categories[0] == "!"
? localMappedCategories.Except(SearchPath.Categories).ToList()
: localMappedCategories.Intersect(SearchPath.Categories).ToList();

if (!categories.Any())
{
continue;
}

variables[".Categories"] = mappedCategories.Intersect(SearchPath.Categories).ToList();
variables[".Categories"] = categories;
}

// build search URL
Expand Down Expand Up @@ -1484,11 +1485,11 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
}
}

if (method == RequestType.GET)
if (method == RequestType.GET && queryCollection.Count > 0)
{
if (queryCollection.Count > 0)
searchUrl += "?" + queryCollection.GetQueryString(Encoding);
searchUrl += "?" + queryCollection.GetQueryString(Encoding);
}

var searchUrlUri = new Uri(searchUrl);

// send HTTP request
Expand Down

0 comments on commit 5ebe1de

Please sign in to comment.