Skip to content

Commit

Permalink
cardigann: respect the categories from search paths (#14395)
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed May 28, 2023
1 parent 12da8b6 commit 7e7ace0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Jackett.Common/Indexers/CardigannIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1349,8 +1349,6 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
mappedCategories = DefaultCategories;
}

variables[".Categories"] = mappedCategories;

var KeywordTokens = new List<string>();
var KeywordTokenKeys = new List<string> { "Q", "Series", "Movie", "Year" };
foreach (var key in KeywordTokenKeys)
Expand All @@ -1369,15 +1367,26 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
var SearchPaths = Search.Paths;
foreach (var SearchPath in SearchPaths)
{
variables[".Categories"] = mappedCategories;

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

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

if (!hasIntersect)
{
variables[".Categories"] = mappedCategories.Except(SearchPath.Categories).ToList();

continue;
}

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

// build search URL
Expand Down

0 comments on commit 7e7ace0

Please sign in to comment.