Skip to content

Commit

Permalink
New: Add download directory & move completed for Deluge
Browse files Browse the repository at this point in the history
(cherry picked from commit 07bd159436935a7adb87ae1b6924a4d42d719b0f)
  • Loading branch information
nopoz authored and mynameisbogdan committed Mar 3, 2024
1 parent 475590a commit cea5ee5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
38 changes: 30 additions & 8 deletions src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -101,11 +103,21 @@ public DelugeTorrent[] GetTorrentsByLabel(string label, DelugeSettings settings)

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);

Expand All @@ -114,11 +126,21 @@ public string AddTorrentFromMagnet(string magnetLink, DelugeSettings settings)

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;
Expand Down
6 changes: 6 additions & 0 deletions src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public DelugeSettings()
[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));
Expand Down
4 changes: 4 additions & 0 deletions src/NzbDrone.Core/Localization/Core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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+)",
Expand Down

0 comments on commit cea5ee5

Please sign in to comment.