Skip to content

Commit

Permalink
Fixed: (Cardigann) Respect the categories from search paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed May 28, 2023
1 parent 59b6e8a commit ef1ad59
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,6 @@ private IEnumerable<IndexerRequest> GetRequest(Dictionary<string, object> variab
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 @@ -1069,20 +1067,26 @@ private IEnumerable<IndexerRequest> GetRequest(Dictionary<string, object> variab
var searchPaths = search.Paths;
foreach (var searchPath in searchPaths)
{
variables[".Categories"] = mappedCategories;

// skip path if categories don't match
if (searchPath.Categories != null && mappedCategories.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 ef1ad59

Please sign in to comment.