From 75b486c6c8d9965cf4b745f050cf6aa0084c70a5 Mon Sep 17 00:00:00 2001 From: cookandy Date: Tue, 18 Sep 2018 08:24:55 -0700 Subject: [PATCH] Added: "Add Paused" option to Deluge and Transmission (#3038) --- .../Download/Clients/Deluge/Deluge.cs | 4 ---- .../Download/Clients/Deluge/DelugeProxy.cs | 18 ++++++++++++++---- .../Download/Clients/Deluge/DelugeSettings.cs | 5 ++++- .../Clients/Transmission/TransmissionProxy.cs | 2 ++ .../Transmission/TransmissionSettings.cs | 5 ++++- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index 6c8185006..803fdd662 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -42,8 +42,6 @@ namespace NzbDrone.Core.Download.Clients.Deluge _proxy.SetLabel(actualHash, Settings.MovieCategory, Settings); } - _proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings); - var isRecentMovie = remoteMovie.Movie.IsRecentMovie; if (isRecentMovie && Settings.RecentMoviePriority == (int)DelugePriority.First || @@ -64,8 +62,6 @@ namespace NzbDrone.Core.Download.Clients.Deluge _proxy.SetLabel(actualHash, Settings.MovieCategory, Settings); } - _proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings); - var isRecentMovie = remoteMovie.Movie.IsRecentMovie; if (isRecentMovie && Settings.RecentMoviePriority == (int)DelugePriority.First || diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs index 3406685db..5667ab8ed 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -84,21 +84,31 @@ namespace NzbDrone.Core.Download.Clients.Deluge public string AddTorrentFromMagnet(string magnetLink, DelugeSettings settings) { - var response = ProcessRequest(settings, "core.add_torrent_magnet", magnetLink, new JObject()); + var options = new + { + add_paused = settings.AddPaused, + remove_at_ratio = false + }; + var response = ProcessRequest(settings, "core.add_torrent_magnet", magnetLink, options); return response; } public string AddTorrentFromFile(string filename, byte[] fileContent, DelugeSettings settings) { - var response = ProcessRequest(settings, "core.add_torrent_file", filename, fileContent, new JObject()); + var options = new + { + add_paused = settings.AddPaused, + remove_at_ratio = false + }; + var response = ProcessRequest(settings, "core.add_torrent_file", filename, fileContent, options); return response; } - public bool RemoveTorrent(string hashString, bool removeData, DelugeSettings settings) + public bool RemoveTorrent(string hash, bool removeData, DelugeSettings settings) { - var response = ProcessRequest(settings, "core.remove_torrent", hashString, removeData); + var response = ProcessRequest(settings, "core.remove_torrent", hash, removeData); return response; } diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs index ad8794314..9b0010f67 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs @@ -49,7 +49,10 @@ namespace NzbDrone.Core.Download.Clients.Deluge [FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(DelugePriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")] public int OlderMoviePriority { get; set; } - [FieldDefinition(7, Label = "Use SSL", Type = FieldType.Checkbox)] + [FieldDefinition(7, Label = "Add Paused", Type = FieldType.Checkbox)] + public bool AddPaused { get; set; } + + [FieldDefinition(8, Label = "Use SSL", Type = FieldType.Checkbox)] public bool UseSsl { get; set; } public NzbDroneValidationResult Validate() diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs index cada83cae..22457eb24 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs @@ -51,6 +51,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission { var arguments = new Dictionary(); arguments.Add("filename", torrentUrl); + arguments.Add("paused", settings.AddPaused); if (!downloadDirectory.IsNullOrWhiteSpace()) { @@ -64,6 +65,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission { var arguments = new Dictionary(); arguments.Add("metainfo", Convert.ToBase64String(torrentData)); + arguments.Add("paused", settings.AddPaused); if (!downloadDirectory.IsNullOrWhiteSpace()) { diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs index dbd01fda4..70001591c 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs @@ -63,7 +63,10 @@ namespace NzbDrone.Core.Download.Clients.Transmission [FieldDefinition(8, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(TransmissionPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")] public int OlderMoviePriority { get; set; } - [FieldDefinition(9, Label = "Use SSL", Type = FieldType.Checkbox)] + [FieldDefinition(9, Label = "Add Paused", Type = FieldType.Checkbox)] + public bool AddPaused { get; set; } + + [FieldDefinition(10, Label = "Use SSL", Type = FieldType.Checkbox)] public bool UseSsl { get; set; } public NzbDroneValidationResult Validate()