Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Added Radarr/Sonarr config to config-manager in backend.

nzbdav-dev698b5bcaebca
diff --git a/backend/Config/ArrConfig.cs b/backend/Config/ArrConfig.cs
new file mode 100644
index 00000000..987746ad
--- /dev/null
+++ b/backend/Config/ArrConfig.cs
@@ -0,0 +1,28 @@
+namespace NzbWebDAV.Config;
+
+public class ArrConfig
+{
+ public List<ConnectionDetails> RadarrInstances { get; set; } = [];
+ public List<ConnectionDetails> SonarrInstances { get; set; } = [];
+ public List<QueueRule> QueueRules { get; set; } = [];
+
+ public class ConnectionDetails
+ {
+ public required string Host { get; set; }
+ public required string ApiKey { get; set; }
+ }
+
+ public class QueueRule
+ {
+ public string Message { get; set; } = null!;
+ public QueueAction Action { get; set; }
+ }
+
+ public enum QueueAction
+ {
+ DoNothing = 0,
+ Remove = 1,
+ RemoveAndBlocklist = 2,
+ RemoveAndBlocklistAndSearch = 3
+ }
+}
\ No newline at end of file
diff --git a/backend/Config/ConfigManager.cs b/backend/Config/ConfigManager.cs
index 60193097..e361760c 100644
--- a/backend/Config/ConfigManager.cs
+++ b/backend/Config/ConfigManager.cs
@@ -1,4 +1,5 @@
-using Microsoft.EntityFrameworkCore;
+using System.Text.Json;
+using Microsoft.EntityFrameworkCore;
using NzbWebDAV.Database;
using NzbWebDAV.Database.Models;
using NzbWebDAV.Utils;
@@ -32,6 +33,12 @@ public class ConfigManager
}
}
+ public T? GetConfigValue<T>(string configName)
+ {
+ var rawValue = StringUtil.EmptyToNull(GetConfigValue(configName));
+ return rawValue == null ? default : JsonSerializer.Deserialize<T>(rawValue);
+ }
+
public void UpdateValues(List<ConfigItem> configItems)
{
lock (_config)
@@ -149,6 +156,12 @@ public class ConfigManager
return (configValue != null ? bool.Parse(configValue) : defaultValue);
}
+ public ArrConfig GetArrConfig()
+ {
+ var defaultValue = new ArrConfig();
+ return GetConfigValue<ArrConfig>("arr.instances") ?? defaultValue;
+ }
+
public class ConfigEventArgs : EventArgs
{
public Dictionary<string, string> ChangedConfig { get; set; } = new();