From 55ce1394c6a2e3b6e374d36a1ceb97e6ae4141b5 Mon Sep 17 00:00:00 2001 From: kaso17 Date: Mon, 6 Nov 2017 17:16:29 +0100 Subject: [PATCH] Cardigann template: add if support for collections --- src/Jackett.Common/Indexers/CardigannIndexer.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Jackett.Common/Indexers/CardigannIndexer.cs b/src/Jackett.Common/Indexers/CardigannIndexer.cs index cf013b5b5..1eeb50103 100644 --- a/src/Jackett.Common/Indexers/CardigannIndexer.cs +++ b/src/Jackett.Common/Indexers/CardigannIndexer.cs @@ -20,6 +20,7 @@ using System.Linq; using System.Net; using Microsoft.AspNetCore.WebUtilities; using Jacket.Common.Helpers; +using System.Collections; namespace Jackett.Indexers { @@ -262,8 +263,17 @@ namespace Jackett.Indexers if (condition.StartsWith(".")) { - string value = (string)variables[condition]; - if (!string.IsNullOrWhiteSpace(value)) + var conditionResultState = false; + var value = variables[condition]; + + if (value is string) + conditionResultState = !string.IsNullOrWhiteSpace((string)value); + else if(value is ICollection) + conditionResultState = ((ICollection)value).Count > 0; + else + throw new Exception(string.Format("Unexpceted type for variable {0}: {1}", condition, value.GetType())); + + if (conditionResultState) { conditionResult = onTrue; }