From 5d6b71b7a714ecd9f86ca5a08a6945fcd9cb32b3 Mon Sep 17 00:00:00 2001 From: kaso17 Date: Tue, 17 Oct 2017 18:23:13 +0200 Subject: [PATCH] Cardigann: add Preprocessing Filters --- src/Jackett/Indexers/CardigannIndexer.cs | 15 +++++++++++++++ src/Jackett/Models/IndexerDefinition.cs | 1 + 2 files changed, 16 insertions(+) diff --git a/src/Jackett/Indexers/CardigannIndexer.cs b/src/Jackett/Indexers/CardigannIndexer.cs index e9fbe13fd..2392494bb 100644 --- a/src/Jackett/Indexers/CardigannIndexer.cs +++ b/src/Jackett/Indexers/CardigannIndexer.cs @@ -862,6 +862,14 @@ namespace Jackett.Indexers else throw new Exception("unsupported diacritics filter argument"); break; + case "jsonjoinarray": + var jsonjoinarrayJSONPath = (string)Filter.Args[0]; + var jsonjoinarraySeparator = (string)Filter.Args[1]; + var jsonjoinarrayO = JObject.Parse(Data); + var jsonjoinarrayOResult = jsonjoinarrayO.SelectToken(jsonjoinarrayJSONPath); + var jsonjoinarrayOResultStrings = jsonjoinarrayOResult.Select(j => j.ToString()); + Data = string.Join(jsonjoinarraySeparator, jsonjoinarrayOResultStrings); + break; case "hexdump": // this is mainly for debugging invisible special char related issues var HexData = string.Join("", Data.Select(c => c + "(" + ((int)c).ToString("X2") + ")")); @@ -1085,6 +1093,13 @@ namespace Jackett.Indexers else response = await RequestStringWithCookies(searchUrl, null, null, headers); var results = response.Content; + + if (Search.Preprocessingfilters != null) + { + results = applyFilters(results, Search.Preprocessingfilters, variables); + logger.Debug(string.Format("CardigannIndexer ({0}): result after preprocessingfilters: {1}", ID, results)); + } + try { var SearchResultParser = new HtmlParser(); diff --git a/src/Jackett/Models/IndexerDefinition.cs b/src/Jackett/Models/IndexerDefinition.cs index efee0c8ab..211637049 100644 --- a/src/Jackett/Models/IndexerDefinition.cs +++ b/src/Jackett/Models/IndexerDefinition.cs @@ -165,6 +165,7 @@ namespace Jackett.Models public List Keywordsfilters { get; set; } public Dictionary Inputs { get; set; } public List Error { get; set; } + public List Preprocessingfilters { get; set; } public rowsBlock Rows { get; set; } public KeyValuePairList Fields { get; set; } }