New: Add download directory & move completed for Deluge

Closes #4575
This commit is contained in:
nopoz 2024-03-02 21:22:03 -08:00 committed by GitHub
parent 20273b07ad
commit 07bd159436
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 10 deletions

View File

@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Net;
using Newtonsoft.Json.Linq;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Common.Serializer;
@ -101,11 +103,21 @@ namespace NzbDrone.Core.Download.Clients.Deluge
public string AddTorrentFromMagnet(string magnetLink, DelugeSettings settings)
{
var options = new
{
add_paused = settings.AddPaused,
remove_at_ratio = false
};
dynamic options = new ExpandoObject();
options.add_paused = settings.AddPaused;
options.remove_at_ratio = false;
if (settings.DownloadDirectory.IsNotNullOrWhiteSpace())
{
options.download_location = settings.DownloadDirectory;
}
if (settings.CompletedDirectory.IsNotNullOrWhiteSpace())
{
options.move_completed_path = settings.CompletedDirectory;
options.move_completed = true;
}
var response = ProcessRequest<string>(settings, "core.add_torrent_magnet", magnetLink, options);
@ -114,11 +126,21 @@ namespace NzbDrone.Core.Download.Clients.Deluge
public string AddTorrentFromFile(string filename, byte[] fileContent, DelugeSettings settings)
{
var options = new
{
add_paused = settings.AddPaused,
remove_at_ratio = false
};
dynamic options = new ExpandoObject();
options.add_paused = settings.AddPaused;
options.remove_at_ratio = false;
if (settings.DownloadDirectory.IsNotNullOrWhiteSpace())
{
options.download_location = settings.DownloadDirectory;
}
if (settings.CompletedDirectory.IsNotNullOrWhiteSpace())
{
options.move_completed_path = settings.CompletedDirectory;
options.move_completed = true;
}
var response = ProcessRequest<string>(settings, "core.add_torrent_file", filename, fileContent, options);

View File

@ -61,6 +61,12 @@ namespace NzbDrone.Core.Download.Clients.Deluge
[FieldDefinition(9, Label = "DownloadClientSettingsAddPaused", Type = FieldType.Checkbox)]
public bool AddPaused { get; set; }
[FieldDefinition(10, Label = "DownloadClientDelugeSettingsDirectory", Type = FieldType.Textbox, Advanced = true, HelpText = "DownloadClientDelugeSettingsDirectoryHelpText")]
public string DownloadDirectory { get; set; }
[FieldDefinition(11, Label = "DownloadClientDelugeSettingsDirectoryCompleted", Type = FieldType.Textbox, Advanced = true, HelpText = "DownloadClientDelugeSettingsDirectoryCompletedHelpText")]
public string CompletedDirectory { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -413,6 +413,10 @@
"DownloadClientDelugeValidationLabelPluginFailureDetail": "{appName} was unable to add the label to {clientName}.",
"DownloadClientDelugeValidationLabelPluginInactive": "Label plugin not activated",
"DownloadClientDelugeValidationLabelPluginInactiveDetail": "You must have the Label plugin enabled in {clientName} to use categories.",
"DownloadClientDelugeSettingsDirectory": "Download Directory",
"DownloadClientDelugeSettingsDirectoryHelpText": "Optional location to put downloads in, leave blank to use the default Deluge location",
"DownloadClientDelugeSettingsDirectoryCompleted": "Move When Completed Directory",
"DownloadClientDelugeSettingsDirectoryCompletedHelpText": "Optional location to move completed downloads to, leave blank to use the default Deluge location",
"DownloadClientDownloadStationProviderMessage": "{appName} is unable to connect to Download Station if 2-Factor Authentication is enabled on your DSM account",
"DownloadClientDownloadStationSettingsDirectoryHelpText": "Optional shared folder to put downloads into, leave blank to use the default Download Station location",
"DownloadClientDownloadStationValidationApiVersion": "Download Station API version not supported, should be at least {requiredVersion}. It supports from {minVersion} to {maxVersion}",