From 9dfa8c5b10b5ff6062d231a4a2002e9f495ca245 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 14 Jan 2018 15:01:31 -0500 Subject: [PATCH] New: Add paused options for Deluge and Transmission --- .../Download/Clients/Deluge/Deluge.cs | 10 +++------- .../Download/Clients/Deluge/DelugeProxy.cs | 19 +++++++++++++++---- .../Download/Clients/Deluge/DelugeSettings.cs | 7 +++++-- .../Download/Clients/Nzbget/NzbgetSettings.cs | 10 +++++----- .../Clients/Transmission/TransmissionProxy.cs | 2 ++ .../Transmission/TransmissionSettings.cs | 7 +++++-- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index c0636cdd0..fbe6367b7 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -40,8 +40,6 @@ namespace NzbDrone.Core.Download.Clients.Deluge _proxy.SetLabel(actualHash, Settings.TvCategory, Settings); } - _proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings); - var isRecentAlbum = remoteAlbum.IsRecentAlbum(); if (isRecentAlbum && Settings.RecentTvPriority == (int)DelugePriority.First || @@ -67,12 +65,10 @@ namespace NzbDrone.Core.Download.Clients.Deluge _proxy.SetLabel(actualHash, Settings.TvCategory, Settings); } - _proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings); - - var isRecentEpisode = remoteAlbum.IsRecentAlbum(); + var isRecentAlbum = remoteAlbum.IsRecentAlbum(); - if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First || - !isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First) + if (isRecentAlbum && Settings.RecentTvPriority == (int)DelugePriority.First || + !isRecentAlbum && Settings.OlderTvPriority == (int)DelugePriority.First) { _proxy.MoveTorrentToTopInQueue(actualHash, Settings); } diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs index 62dd60529..ac1823340 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -84,21 +84,32 @@ 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 6fafae599..fa0962c29 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeSettings.cs @@ -1,4 +1,4 @@ -using FluentValidation; +using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -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 albums released over 14 days ago")] public int OlderTvPriority { 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/Nzbget/NzbgetSettings.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs index 8a75be249..acaab3f4b 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs @@ -1,4 +1,4 @@ -using FluentValidation; +using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -54,12 +54,12 @@ namespace NzbDrone.Core.Download.Clients.Nzbget [FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(NzbgetPriority), HelpText = "Priority to use when grabbing albums released over 14 days ago")] public int OlderTvPriority { get; set; } - [FieldDefinition(7, Label = "Use SSL", Type = FieldType.Checkbox)] - public bool UseSsl { get; set; } - - [FieldDefinition(8, Label = "Add Paused", Type = FieldType.Checkbox, HelpText = "This option requires at least NzbGet version 16.0")] + [FieldDefinition(7, Label = "Add Paused", Type = FieldType.Checkbox, HelpText = "This option requires at least NzbGet version 16.0")] public bool AddPaused { get; set; } + [FieldDefinition(8, Label = "Use SSL", Type = FieldType.Checkbox)] + public bool UseSsl { get; set; } + public NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this)); diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs index 7c06b9278..a365046fa 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 9626eb7f7..0437d5a27 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionSettings.cs @@ -1,4 +1,4 @@ -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -62,7 +62,10 @@ namespace NzbDrone.Core.Download.Clients.Transmission [FieldDefinition(8, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(TransmissionPriority), HelpText = "Priority to use when grabbing albums released over 14 days ago")] public int OlderTvPriority { 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()