From b7341b20f4f92bfbcc799edfb4f5cb0edc255321 Mon Sep 17 00:00:00 2001 From: XYZJR <50780760+XYZJR@users.noreply.github.com> Date: Wed, 17 Mar 2021 14:01:58 +0100 Subject: [PATCH] Add all configuration item types to GetBaseTemplateVariables (#11332) resolves #11328 --- .../Indexers/CardigannIndexer.cs | 66 ++++++++++++++++--- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/src/Jackett.Common/Indexers/CardigannIndexer.cs b/src/Jackett.Common/Indexers/CardigannIndexer.cs index c3042cced..240f859bb 100644 --- a/src/Jackett.Common/Indexers/CardigannIndexer.cs +++ b/src/Jackett.Common/Indexers/CardigannIndexer.cs @@ -229,17 +229,65 @@ namespace Jackett.Common.Indexers [".False"] = null, [".Today.Year"] = DateTime.Today.Year.ToString() }; + foreach (var setting in Definition.Settings) - variables[".Config." + setting.Name] = configData.GetDynamic(setting.Name) switch + { + var configurationItem = configData.GetDynamic(setting.Name); + if (configurationItem == null) + continue; + + var variableKey = ".Config." + setting.Name; + + switch (configurationItem) { - MultiSelectConfigurationItem checkbox => checkbox.Values, - BoolConfigurationItem boolItem => variables[boolItem.Value ? ".True" : ".False"], - SingleSelectConfigurationItem selectItem => selectItem.Value, - StringConfigurationItem stringItem => stringItem.Value, - // Throw exception here to match original functionality. - // Currently this will only throw for ImageItem. - _ => throw new NotSupportedException() - }; + case BoolConfigurationItem boolItem: + { + variables[variableKey] = variables[boolItem.Value ? ".True" : ".False"]; + break; + } + case StringConfigurationItem stringItem: + { + variables[variableKey] = stringItem.Value; + break; + } + case PasswordConfigurationItem passwordItem: + { + variables[variableKey] = passwordItem.Value; + break; + } + case SingleSelectConfigurationItem selectItem: + { + variables[variableKey] = selectItem.Value; + break; + } + case MultiSelectConfigurationItem multiSelectItem: + { + variables[variableKey] = multiSelectItem.Values; + break; + } + case DisplayImageConfigurationItem displayImageItem: + { + variables[variableKey] = displayImageItem.Value; + break; + } + case DisplayInfoConfigurationItem displayInfoItem: + { + variables[variableKey] = displayInfoItem.Value; + break; + } + case HiddenStringConfigurationItem hiddenStringItem: + { + variables[variableKey] = hiddenStringItem.Value; + break; + } + default: + { + //TODO Should this throw a NotSupportedException, as it used to? + break; + } + } + } + return variables; }