From 967839154c308eae932532c7857ec943379e85dc Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 29 Oct 2017 17:14:01 -0400 Subject: [PATCH] New: Start torrents added to uTorrent by default, add option --- .../Download/Clients/uTorrent/UTorrent.cs | 18 +++++++++++++++++ .../Clients/uTorrent/UTorrentProxy.cs | 20 +++++++++++++++++++ .../Clients/uTorrent/UTorrentSettings.cs | 5 ++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index 034ae1e46..d6df4c2e8 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -49,6 +49,15 @@ protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash _proxy.MoveTorrentToTopInQueue(hash, Settings); } + if (Settings.AddStopped) + { + _proxy.StopTorrent(hash, Settings); + } + else + { + _proxy.StartTorrent(hash, Settings); + } + return hash; } @@ -65,6 +74,15 @@ protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string has _proxy.MoveTorrentToTopInQueue(hash, Settings); } + if (Settings.AddStopped) + { + _proxy.StopTorrent(hash, Settings); + } + else + { + _proxy.StartTorrent(hash, Settings); + } + return hash; } diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs index 662b5322c..08d0c8186 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs @@ -22,6 +22,8 @@ public interface IUTorrentProxy void RemoveTorrent(string hash, bool removeData, UTorrentSettings settings); void SetTorrentLabel(string hash, string label, UTorrentSettings settings); void MoveTorrentToTopInQueue(string hash, UTorrentSettings settings); + void StartTorrent(string hash, UTorrentSettings settings); + void StopTorrent(string hash, UTorrentSettings settings); } public class UTorrentProxy : IUTorrentProxy @@ -157,6 +159,24 @@ public void MoveTorrentToTopInQueue(string hash, UTorrentSettings settings) ProcessRequest(requestBuilder, settings); } + public void StartTorrent(string hash, UTorrentSettings settings) + { + var requestBuilder = BuildRequest(settings) + .AddQueryParam("action", "start") + .AddQueryParam("hash", hash); + + ProcessRequest(requestBuilder, settings); + } + + public void StopTorrent(string hash, UTorrentSettings settings) + { + var requestBuilder = BuildRequest(settings) + .AddQueryParam("action", "stop") + .AddQueryParam("hash", hash); + + ProcessRequest(requestBuilder, settings); + } + private HttpRequestBuilder BuildRequest(UTorrentSettings settings) { var requestBuilder = new HttpRequestBuilder(false, settings.Host, settings.Port) diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs index 103bec26e..30ab7f4df 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs @@ -1,4 +1,4 @@ -using FluentValidation; +using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -47,6 +47,9 @@ public UTorrentSettings() [FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(UTorrentPriority), HelpText = "Priority to use when grabbing albums released over 14 days ago")] public int OlderTvPriority { get; set; } + [FieldDefinition(7, Label = "Add Stopped", Type = FieldType.Checkbox, SelectOptions = typeof(UTorrentPriority), HelpText = "Torrents will need to be started manually in uTorrent")] + public bool AddStopped { get; set; } + public NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this));