Skip to content

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

C#

Added UI setting to fail downloads when no videos are found inside an nzb.

nzbdav-dev06e4fd2f962a
diff --git a/backend/Config/ConfigManager.cs b/backend/Config/ConfigManager.cs
index 594f438b..8d14d2af 100644
--- a/backend/Config/ConfigManager.cs
+++ b/backend/Config/ConfigManager.cs
@@ -93,6 +93,13 @@ public class ConfigManager
return null;
}
+ public bool IsEnsureImportableVideoEnabled()
+ {
+ var defaultValue = true;
+ var configValue = StringUtil.EmptyToNull(GetConfigValue("api.ensure-importable-video"));
+ return (configValue != null ? bool.Parse(configValue) : defaultValue);
+ }
+
public class ConfigEventArgs : EventArgs
{
public Dictionary<string, string> ChangedConfig { get; set; } = new();
diff --git a/backend/Services/QueueItemProcessor.cs b/backend/Services/QueueItemProcessor.cs
index 8e911f85..6c658898 100644
--- a/backend/Services/QueueItemProcessor.cs
+++ b/backend/Services/QueueItemProcessor.cs
@@ -1,6 +1,7 @@
using System.Text;
using Microsoft.EntityFrameworkCore;
using NzbWebDAV.Clients;
+using NzbWebDAV.Config;
using NzbWebDAV.Database;
using NzbWebDAV.Database.Models;
using NzbWebDAV.Extensions;
@@ -17,6 +18,7 @@ public class QueueItemProcessor(
QueueItem queueItem,
DavDatabaseClient dbClient,
UsenetStreamingClient usenetClient,
+ ConfigManager configManager,
IProgress<int> progress,
CancellationToken ct
)
@@ -104,7 +106,8 @@ public class QueueItemProcessor(
new FileAggregator(dbClient, mountFolder).UpdateDatabase(fileProcessingResults);
// validate video files found
- new EnsureImportableVideoValidator(dbClient).ThrowIfValidationFails();
+ if (configManager.IsEnsureImportableVideoEnabled())
+ new EnsureImportableVideoValidator(dbClient).ThrowIfValidationFails();
});
}
diff --git a/backend/Services/QueueManager.cs b/backend/Services/QueueManager.cs
index 42b19500..8a00bbc2 100644
--- a/backend/Services/QueueManager.cs
+++ b/backend/Services/QueueManager.cs
@@ -1,4 +1,5 @@
using NzbWebDAV.Clients;
+using NzbWebDAV.Config;
using NzbWebDAV.Database;
using NzbWebDAV.Database.Models;
using Serilog;
@@ -12,10 +13,12 @@ public class QueueManager : IDisposable
private readonly UsenetStreamingClient _usenetClient;
private readonly CancellationTokenSource? _cancellationTokenSource;
private readonly SemaphoreSlim _semaphore = new(1, 1);
+ private readonly ConfigManager _configManager;
- public QueueManager(UsenetStreamingClient usenetClient)
+ public QueueManager(UsenetStreamingClient usenetClient, ConfigManager configManager)
{
_usenetClient = usenetClient;
+ _configManager = configManager;
_cancellationTokenSource = new CancellationTokenSource();
_ = ProcessQueueAsync(_cancellationTokenSource.Token);
}
@@ -89,7 +92,9 @@ public class QueueManager : IDisposable
)
{
var progressHook = new Progress<int>();
- var task = new QueueItemProcessor(queueItem, dbClient, _usenetClient, progressHook, cts.Token).ProcessAsync();
+ var task = new QueueItemProcessor(
+ queueItem, dbClient, _usenetClient, _configManager, progressHook, cts.Token
+ ).ProcessAsync();
var inProgressQueueItem = new InProgressQueueItem()
{
QueueItem = queueItem,
diff --git a/frontend/app/routes/settings/route.tsx b/frontend/app/routes/settings/route.tsx
index 70b1a019..33d5925b 100644
--- a/frontend/app/routes/settings/route.tsx
+++ b/frontend/app/routes/settings/route.tsx
@@ -4,7 +4,7 @@ import { TopNavigation } from "../_index/components/top-navigation/top-navigatio
import { LeftNavigation } from "../_index/components/left-navigation/left-navigation";
import styles from "./route.module.css"
import { Tabs, Tab, Button } from "react-bootstrap"
-import { backendClient, type ConfigItem } from "~/clients/backend-client.server";
+import { backendClient } from "~/clients/backend-client.server";
import { redirect } from "react-router";
import { sessionStorage } from "~/auth/authentication.server";
import { isUsenetSettingsUpdated, UsenetSettings } from "./usenet/usenet";
@@ -15,6 +15,7 @@ import { isWebdavSettingsUpdated, isWebdavSettingsValid, WebdavSettings } from "
const defaultConfig = {
"api.key": "",
"api.categories": "",
+ "api.ensure-importable-video": "true",
"usenet.host": "",
"usenet.port": "",
"usenet.use-ssl": "false",
diff --git a/frontend/app/routes/settings/sabnzbd/sabnzbd.tsx b/frontend/app/routes/settings/sabnzbd/sabnzbd.tsx
index a584f8a6..44e436fb 100644
--- a/frontend/app/routes/settings/sabnzbd/sabnzbd.tsx
+++ b/frontend/app/routes/settings/sabnzbd/sabnzbd.tsx
@@ -60,7 +60,20 @@ export function SabnzbdSettings({ config, setNewConfig }: SabnzbdSettingsProps)
value={config["rclone.mount-dir"]}
onChange={e => setNewConfig({ ...config, "rclone.mount-dir": e.target.value })} />
<Form.Text id="mount-dir-help" muted>
- The location at which you've mounted (or will mount) the webdav root, through Rclone. This is used to tell sonarr / radarr where to look for completed "downloads."
+ The location at which you've mounted (or will mount) the webdav root, through Rclone. This is used to tell Radarr / Sonarr where to look for completed "downloads."
+ </Form.Text>
+ </Form.Group>
+ <hr />
+ <Form.Group>
+ <Form.Check
+ className={styles.input}
+ type="checkbox"
+ aria-describedby="ensure-importable-video-help"
+ label={`Fail downloads for nzbs without video content`}
+ checked={config["api.ensure-importable-video"] === "true"}
+ onChange={e => setNewConfig({ ...config, "api.ensure-importable-video": "" + e.target.checked })} />
+ <Form.Text id="ensure-importable-video-help" muted>
+ Whether to mark downloads as `failed` when no single video file is found inside the nzb. This will force Radarr / Sonarr to automatically look for a new nzb.
</Form.Text>
</Form.Group>
</div>
@@ -71,6 +84,7 @@ export function isSabnzbdSettingsUpdated(config: Record<string, string>, newConf
return config["api.key"] !== newConfig["api.key"]
|| config["api.categories"] !== newConfig["api.categories"]
|| config["rclone.mount-dir"] !== newConfig["rclone.mount-dir"]
+ || config["api.ensure-importable-video"] !== newConfig["api.ensure-importable-video"]
}
export function isSabnzbdSettingsValid(newConfig: Record<string, string>) {