Set Cardigann defaults on definition load

pull/10/head
Qstick 4 years ago
parent bdcf34aab4
commit ab68c8b5b5

@ -110,6 +110,22 @@ namespace NzbDrone.Core.IndexerVersions
{
var definitionString = File.ReadAllText(file.FullName);
var definition = _deserializer.Deserialize<CardigannDefinition>(definitionString);
//defaults
if (definition.Settings == null)
{
definition.Settings = new List<SettingsField>
{
new SettingsField { Name = "username", Label = "Username", Type = "text" },
new SettingsField { Name = "password", Label = "Password", Type = "password" }
};
}
if (definition.Login != null && definition.Login.Method == null)
{
definition.Login.Method = "form";
}
return definition;
}
catch (Exception e)

@ -216,15 +216,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
_logger.Debug("Populating config vars");
var defaultSettings = new List<SettingsField>
{
new SettingsField { Name = "username", Label = "Username", Type = "text" },
new SettingsField { Name = "password", Label = "Password", Type = "password" }
};
var settings = _definition.Settings ?? defaultSettings;
foreach (var setting in settings)
foreach (var setting in _definition.Settings)
{
var name = ".Config." + setting.Name;
var value = _settings.ExtraFieldData.GetValueOrDefault(setting.Name, setting.Default);

@ -882,6 +882,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
}
request.HttpRequest.Method = method;
request.HttpRequest.SuppressHttpError = true;
yield return request;
}

Loading…
Cancel
Save