New: Add download directory & move completed for Deluge

(cherry picked from commit 07bd159436935a7adb87ae1b6924a4d42d719b0f)
sonarr-pull-e81bb3b9
nopoz 2 months ago committed by Bogdan
parent 475590a21b
commit cea5ee503f

@ -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
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())
{
add_paused = settings.AddPaused,
remove_at_ratio = false
};
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
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())
{
add_paused = settings.AddPaused,
remove_at_ratio = false
};
options.move_completed_path = settings.CompletedDirectory;
options.move_completed = true;
}
var response = ProcessRequest<string>(settings, "core.add_torrent_file", filename, fileContent, options);
return response;

@ -59,6 +59,12 @@ namespace NzbDrone.Core.Download.Clients.Deluge
[FieldDefinition(9, Label = "Add Paused", 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));

@ -362,6 +362,10 @@
"DownloadClientCheckDownloadingToRoot": "Download client {0} places downloads in the root folder {1}. You should not download to a root folder.",
"DownloadClientCheckNoneAvailableMessage": "No download client is available",
"DownloadClientCheckUnableToCommunicateMessage": "Unable to communicate with {0}.",
"DownloadClientDelugeSettingsDirectory": "Download Directory",
"DownloadClientDelugeSettingsDirectoryCompleted": "Move When Completed Directory",
"DownloadClientDelugeSettingsDirectoryCompletedHelpText": "Optional location to move completed downloads to, leave blank to use the default Deluge location",
"DownloadClientDelugeSettingsDirectoryHelpText": "Optional location to put downloads in, leave blank to use the default Deluge location",
"DownloadClientPriorityHelpText": "Download Client Priority from 1 (Highest) to 50 (Lowest). Default: 1. Round-Robin is used for clients with the same priority.",
"DownloadClientQbittorrentSettingsContentLayout": "Content Layout",
"DownloadClientQbittorrentSettingsContentLayoutHelpText": "Whether to use qBittorrent's configured content layout, the original layout from the torrent or always create a subfolder (qBittorrent 4.3.2+)",

Loading…
Cancel
Save