From ddd119a4ebf8c80eefa1dfd8cacccf7e3ac3c265 Mon Sep 17 00:00:00 2001 From: vertigo235 Date: Wed, 8 Feb 2017 23:36:39 -0500 Subject: [PATCH] New: Add paused option for NZBGet Closes #346 --- .../DownloadClientTests/NzbgetTests/NzbgetFixture.cs | 4 ++-- src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs | 5 ++++- src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs | 6 +++--- src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs | 3 +++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs index 98eb0d35b..226288464 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs @@ -92,14 +92,14 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests protected void GivenFailedDownload() { Mocker.GetMock() - .Setup(s => s.DownloadNzb(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Setup(s => s.DownloadNzb(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns((string)null); } protected void GivenSuccessfulDownload() { Mocker.GetMock() - .Setup(s => s.DownloadNzb(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Setup(s => s.DownloadNzb(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(Guid.NewGuid().ToString().Replace("-", "")); } diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index aa05aec26..72cec8d75 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -32,9 +32,12 @@ namespace NzbDrone.Core.Download.Clients.Nzbget protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) { var category = Settings.TvCategory; + var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; - var response = _proxy.DownloadNzb(fileContent, filename, category, priority, Settings); + var addpaused = Settings.AddPaused; + + var response = _proxy.DownloadNzb(fileContent, filename, category, priority, addpaused, Settings); if (response == null) { diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs index 0434832b6..7a21b45b1 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget { public interface INzbgetProxy { - string DownloadNzb(byte[] nzbData, string title, string category, int priority, NzbgetSettings settings); + string DownloadNzb(byte[] nzbData, string title, string category, int priority, bool addpaused, NzbgetSettings settings); NzbgetGlobalStatus GetGlobalStatus(NzbgetSettings settings); List GetQueue(NzbgetSettings settings); List GetHistory(NzbgetSettings settings); @@ -45,12 +45,12 @@ namespace NzbDrone.Core.Download.Clients.Nzbget return version >= minimumVersion; } - public string DownloadNzb(byte[] nzbData, string title, string category, int priority, NzbgetSettings settings) + public string DownloadNzb(byte[] nzbData, string title, string category, int priority, bool addpaused, NzbgetSettings settings) { if (HasVersion(16, settings)) { var droneId = Guid.NewGuid().ToString().Replace("-", ""); - var response = ProcessRequest(settings, "append", title, nzbData, category, priority, false, false, string.Empty, 0, "all", new string[] { "drone", droneId }); + var response = ProcessRequest(settings, "append", title, nzbData, category, priority, false, addpaused, string.Empty, 0, "all", new string[] { "drone", droneId }); if (response <= 0) { return null; diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs index 59acfde42..667312174 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs @@ -55,6 +55,9 @@ namespace NzbDrone.Core.Download.Clients.Nzbget [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")] + public bool AddPaused { get; set; } + public NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this));