From 98e94643fb9dbb78ab9fdc4a555c13dbf409b957 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 7 Jul 2013 20:15:15 -0700 Subject: [PATCH] Episodes older than 14 days have their own priority --- .../BlackholeProviderFixture.cs | 33 ++++++++----- .../NzbgetProviderTests/DownloadNzbFixture.cs | 18 ++++--- .../PneumaticProviderFixture.cs | 48 ++++++++++++------- .../SabProviderTests/SabProviderFixture.cs | 18 ++++--- .../Download/DownloadServiceFixture.cs | 11 ++--- NzbDrone.Core/Configuration/ConfigService.cs | 14 ++++++ NzbDrone.Core/Configuration/IConfigService.cs | 2 + .../Download/Clients/BlackholeProvider.cs | 5 +- .../Download/Clients/Nzbget/NzbgetClient.cs | 8 +++- .../Download/Clients/PneumaticClient.cs | 7 ++- .../Download/Clients/Sabnzbd/SabnzbdClient.cs | 9 ++-- NzbDrone.Core/Download/DownloadService.cs | 5 +- NzbDrone.Core/Download/IDownloadClient.cs | 3 +- NzbDrone.Core/Parser/Model/RemoteEpisode.cs | 7 +++ .../DownloadClient/NzbgetViewTemplate.html | 21 +++++++- .../DownloadClient/SabViewTemplate.html | 21 +++++++- 16 files changed, 164 insertions(+), 66 deletions(-) diff --git a/NzbDrone.Core.Test/Download/DownloadClientTests/BlackholeProviderFixture.cs b/NzbDrone.Core.Test/Download/DownloadClientTests/BlackholeProviderFixture.cs index 3907fe725..67d0e455e 100644 --- a/NzbDrone.Core.Test/Download/DownloadClientTests/BlackholeProviderFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadClientTests/BlackholeProviderFixture.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download.Clients; +using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -14,21 +15,26 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests [TestFixture] public class BlackholeProviderFixture : CoreTest { - private const string nzbUrl = "http://www.nzbs.com/url"; - private const string title = "some_nzb_title"; - private const string blackHoleFolder = @"d:\nzb\blackhole\"; - private const string nzbPath = @"d:\nzb\blackhole\some_nzb_title.nzb"; + private const string _nzbUrl = "http://www.nzbs.com/url"; + private const string _title = "some_nzb_title"; + private const string _blackHoleFolder = @"d:\nzb\blackhole\"; + private const string _nzbPath = @"d:\nzb\blackhole\some_nzb_title.nzb"; + private RemoteEpisode _remoteEpisode; [SetUp] public void Setup() { - Mocker.GetMock().SetupGet(c => c.BlackholeFolder).Returns(blackHoleFolder); - } + Mocker.GetMock().SetupGet(c => c.BlackholeFolder).Returns(_blackHoleFolder); + _remoteEpisode = new RemoteEpisode(); + _remoteEpisode.Report = new ReportInfo(); + _remoteEpisode.Report.Title = _title; + _remoteEpisode.Report.NzbUrl = _nzbUrl; + } private void WithExistingFile() { - Mocker.GetMock().Setup(c => c.FileExists(nzbPath)).Returns(true); + Mocker.GetMock().Setup(c => c.FileExists(_nzbPath)).Returns(true); } private void WithFailedDownload() @@ -39,9 +45,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests [Test] public void DownloadNzb_should_download_file_if_it_doesnt_exist() { - Subject.DownloadNzb(nzbUrl, title).Should().BeTrue(); + Subject.DownloadNzb(_remoteEpisode).Should().BeTrue(); - Mocker.GetMock().Verify(c => c.DownloadFile(nzbUrl, nzbPath), Times.Once()); + Mocker.GetMock().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath), Times.Once()); } [Test] @@ -49,7 +55,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests { WithExistingFile(); - Subject.DownloadNzb(nzbUrl, title).Should().BeTrue(); + Subject.DownloadNzb(_remoteEpisode).Should().BeTrue(); Mocker.GetMock().Verify(c => c.DownloadFile(It.IsAny(), It.IsAny()), Times.Never()); } @@ -59,7 +65,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests { WithFailedDownload(); - Subject.DownloadNzb(nzbUrl, title).Should().BeFalse(); + Subject.DownloadNzb(_remoteEpisode).Should().BeFalse(); ExceptionVerification.ExpectedWarns(1); } @@ -68,9 +74,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests public void should_replace_illegal_characters_in_title() { var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]"; - var expectedFilename = Path.Combine(blackHoleFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb"); + var expectedFilename = Path.Combine(_blackHoleFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb"); + _remoteEpisode.Report.Title = illegalTitle; - Subject.DownloadNzb(nzbUrl, illegalTitle).Should().BeTrue(); + Subject.DownloadNzb(_remoteEpisode).Should().BeTrue(); Mocker.GetMock().Verify(c => c.DownloadFile(It.IsAny(), expectedFilename), Times.Once()); } diff --git a/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs b/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs index dd694c64d..8e540d505 100644 --- a/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs @@ -5,12 +5,17 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download.Clients.Nzbget; +using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests { public class DownloadNzbFixture : CoreTest { + private const string _url = "http://www.nzbdrone.com"; + private const string _title = "30 Rock - S01E01 - Pilot [HDTV-720p]"; + private RemoteEpisode _remoteEpisode; + [SetUp] public void Setup() { @@ -21,8 +26,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests fakeConfig.SetupGet(c => c.NzbgetPassword).Returns("pass"); fakeConfig.SetupGet(c => c.NzbgetTvCategory).Returns("TV"); fakeConfig.SetupGet(c => c.NzbgetRecentTvPriority).Returns(PriorityType.High); - } + _remoteEpisode = new RemoteEpisode(); + _remoteEpisode.Report = new ReportInfo(); + _remoteEpisode.Report.Title = _title; + _remoteEpisode.Report.NzbUrl = _url; + } private void WithFailResponse() { @@ -34,16 +43,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests [Test] public void should_add_item_to_queue() { - const string url = "http://www.nzbdrone.com"; - const string title = "30 Rock - S01E01 - Pilot [HDTV-720p]"; - Mocker.GetMock() .Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.Is(c => c.Equals("{\"method\":\"appendurl\",\"params\":[\"30 Rock - S01E01 - Pilot [HDTV-720p]\",\"TV\",50,false,\"http://www.nzbdrone.com\"]}")))) .Returns("{\"version\": \"1.1\",\"result\": true}"); Mocker.Resolve() - .DownloadNzb(url, title) + .DownloadNzb(_remoteEpisode) .Should() .BeTrue(); } @@ -53,7 +59,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests { WithFailResponse(); - Assert.Throws(() => Mocker.Resolve().DownloadNzb("http://www.nzbdrone.com", "30 Rock - S01E01 - Pilot [HDTV-720p]")); + Assert.Throws(() => Mocker.Resolve().DownloadNzb(_remoteEpisode)); } } } diff --git a/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs b/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs index 0d54e433a..d02080eff 100644 --- a/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs @@ -6,32 +6,42 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download.Clients; +using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Download.DownloadClientTests { [TestFixture] - public class PneumaticProviderFixture : CoreTest + public class PneumaticProviderFixture : CoreTest { - private const string nzbUrl = "http://www.nzbs.com/url"; - private const string title = "30.Rock.S01E05.hdtv.xvid-LoL"; - private const string pneumaticFolder = @"d:\nzb\pneumatic\"; - private const string sabDrop = @"d:\unsorted tv\"; - private string nzbPath; + private const string _nzbUrl = "http://www.nzbs.com/url"; + private const string _title = "30.Rock.S01E05.hdtv.xvid-LoL"; + private const string _pneumaticFolder = @"d:\nzb\pneumatic\"; + private const string _sabDrop = @"d:\unsorted tv\"; + private string _nzbPath; + private RemoteEpisode _remoteEpisode; [SetUp] public void Setup() { - nzbPath = pneumaticFolder + title + ".nzb"; + _nzbPath = _pneumaticFolder + _title + ".nzb"; - Mocker.GetMock().SetupGet(c => c.PneumaticFolder).Returns(pneumaticFolder); - Mocker.GetMock().SetupGet(c => c.DownloadedEpisodesFolder).Returns(sabDrop); + Mocker.GetMock().SetupGet(c => c.PneumaticFolder).Returns(_pneumaticFolder); + Mocker.GetMock().SetupGet(c => c.DownloadedEpisodesFolder).Returns(_sabDrop); + + _remoteEpisode = new RemoteEpisode(); + _remoteEpisode.Report = new ReportInfo(); + _remoteEpisode.Report.Title = _title; + _remoteEpisode.Report.NzbUrl = _nzbUrl; + + _remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo(); + _remoteEpisode.ParsedEpisodeInfo.FullSeason = false; } private void WithExistingFile() { - Mocker.GetMock().Setup(c => c.FileExists(nzbPath)).Returns(true); + Mocker.GetMock().Setup(c => c.FileExists(_nzbPath)).Returns(true); } private void WithFailedDownload() @@ -42,9 +52,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests [Test] public void should_download_file_if_it_doesnt_exist() { - Mocker.Resolve().DownloadNzb(nzbUrl, title).Should().BeTrue(); + Subject.DownloadNzb(_remoteEpisode).Should().BeTrue(); - Mocker.GetMock().Verify(c => c.DownloadFile(nzbUrl, nzbPath),Times.Once()); + Mocker.GetMock().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath),Times.Once()); } [Test] @@ -52,7 +62,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests { WithExistingFile(); - Mocker.Resolve().DownloadNzb(nzbUrl, title).Should().BeTrue(); + Subject.DownloadNzb(_remoteEpisode).Should().BeTrue(); Mocker.GetMock().Verify(c => c.DownloadFile(It.IsAny(), It.IsAny()), Times.Never()); } @@ -62,7 +72,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests { WithFailedDownload(); - Mocker.Resolve().DownloadNzb(nzbUrl, title).Should().BeFalse(); + Subject.DownloadNzb(_remoteEpisode).Should().BeFalse(); ExceptionVerification.ExpectedWarns(1); } @@ -70,16 +80,20 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests [Test] public void should_skip_if_full_season_download() { - Mocker.Resolve().DownloadNzb(nzbUrl, "30 Rock - Season 1").Should().BeFalse(); + _remoteEpisode.Report.Title = "30 Rock - Season 1"; + _remoteEpisode.ParsedEpisodeInfo.FullSeason = true; + + Mocker.Resolve().DownloadNzb(_remoteEpisode).Should().BeFalse(); } [Test] public void should_replace_illegal_characters_in_title() { var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]"; - var expectedFilename = Path.Combine(pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb"); + var expectedFilename = Path.Combine(_pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb"); + _remoteEpisode.Report.Title = illegalTitle; - Mocker.Resolve().DownloadNzb(nzbUrl, illegalTitle).Should().BeTrue(); + Subject.DownloadNzb(_remoteEpisode).Should().BeTrue(); Mocker.GetMock().Verify(c => c.DownloadFile(It.IsAny(), expectedFilename), Times.Once()); } diff --git a/NzbDrone.Core.Test/Download/DownloadClientTests/SabProviderTests/SabProviderFixture.cs b/NzbDrone.Core.Test/Download/DownloadClientTests/SabProviderTests/SabProviderFixture.cs index ea7aa7cd5..3eccbca87 100644 --- a/NzbDrone.Core.Test/Download/DownloadClientTests/SabProviderTests/SabProviderFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadClientTests/SabProviderTests/SabProviderFixture.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download.Clients.Sabnzbd; +using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; @@ -17,6 +18,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests { private const string URL = "http://www.nzbclub.com/nzb_download.aspx?mid=1950232"; private const string TITLE = "My Series Name - 5x2-5x3 - My title [Bluray720p] [Proper]"; + private RemoteEpisode _remoteEpisode; [SetUp] public void Setup() @@ -29,6 +31,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests fakeConfig.SetupGet(c => c.SabUsername).Returns("admin"); fakeConfig.SetupGet(c => c.SabPassword).Returns("pass"); fakeConfig.SetupGet(c => c.SabTvCategory).Returns("tv"); + + _remoteEpisode = new RemoteEpisode(); + _remoteEpisode.Report = new ReportInfo(); + _remoteEpisode.Report.Title = TITLE; + _remoteEpisode.Report.NzbUrl = URL; } private void WithFailResponse() @@ -45,14 +52,14 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests .Returns("{ \"status\": true }"); - Subject.DownloadNzb(URL, TITLE).Should().BeTrue(); + Subject.DownloadNzb(_remoteEpisode).Should().BeTrue(); } [Test] public void add_by_url_should_detect_and_handle_sab_errors() { WithFailResponse(); - Assert.Throws(() => Subject.DownloadNzb(URL, TITLE).Should().BeFalse()); + Assert.Throws(() => Subject.DownloadNzb(_remoteEpisode).Should().BeFalse()); } [Test] @@ -186,7 +193,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests Mocker.GetMock() .Setup(s => s.DownloadString(It.IsAny())).Throws(new WebException()); - Subject.DownloadNzb(URL, TITLE).Should().BeFalse(); + Subject.DownloadNzb(_remoteEpisode).Should().BeFalse(); ExceptionVerification.ExpectedErrors(1); } @@ -203,11 +210,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests .Returns("{ \"status\": true }"); - Subject.DownloadNzb(URL, TITLE).Should().BeTrue(); + Subject.DownloadNzb(_remoteEpisode).Should().BeTrue(); Mocker.GetMock() .Verify(v => v.DownloadString("http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=1&pp=3&cat=tv&nzbname=My+Series+Name+-+5x2-5x3+-+My+title+%5bBluray720p%5d+%5bProper%5d&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"), Times.Once()); } - } -} \ No newline at end of file +} diff --git a/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs b/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs index f96126def..8ca5ee37a 100644 --- a/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs +++ b/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs @@ -37,14 +37,14 @@ namespace NzbDrone.Core.Test.Download private void WithSuccessfulAdd() { Mocker.GetMock() - .Setup(s => s.DownloadNzb(It.IsAny(), It.IsAny())) + .Setup(s => s.DownloadNzb(It.IsAny())) .Returns(true); } private void WithFailedAdd() { Mocker.GetMock() - .Setup(s => s.DownloadNzb(It.IsAny(), It.IsAny())) + .Setup(s => s.DownloadNzb(It.IsAny())) .Returns(false); } @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); Mocker.GetMock() - .Verify(s => s.DownloadNzb(It.IsAny(), It.IsAny()), Times.Once()); + .Verify(s => s.DownloadNzb(It.IsAny()), Times.Once()); } [Test] @@ -77,8 +77,5 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); VerifyEventNotPublished(); } - - - } -} \ No newline at end of file +} diff --git a/NzbDrone.Core/Configuration/ConfigService.cs b/NzbDrone.Core/Configuration/ConfigService.cs index 4124b0042..80fec4332 100644 --- a/NzbDrone.Core/Configuration/ConfigService.cs +++ b/NzbDrone.Core/Configuration/ConfigService.cs @@ -109,6 +109,13 @@ namespace NzbDrone.Core.Configuration set { SetValue("SabRecentTvPriority", value); } } + public SabPriorityType SabOlderTvPriority + { + get { return GetValueEnum("SabOlderTvPriority", SabPriorityType.Default); } + + set { SetValue("SabOlderTvPriority", value); } + } + public String DownloadedEpisodesFolder { get { return GetValue("DownloadedEpisodesFolder"); } @@ -251,6 +258,13 @@ namespace NzbDrone.Core.Configuration set { SetValue("NzbgetRecentTvPriority", value); } } + public PriorityType NzbgetOlderTvPriority + { + get { return GetValueEnum("NzbgetOlderTvPriority", PriorityType.Normal); } + + set { SetValue("NzbgetOlderTvPriority", value); } + } + public string ReleaseRestrictions { get { return GetValue("ReleaseRestrictions", String.Empty); } diff --git a/NzbDrone.Core/Configuration/IConfigService.cs b/NzbDrone.Core/Configuration/IConfigService.cs index 83b28a061..cec8ca8ec 100644 --- a/NzbDrone.Core/Configuration/IConfigService.cs +++ b/NzbDrone.Core/Configuration/IConfigService.cs @@ -18,6 +18,7 @@ namespace NzbDrone.Core.Configuration String SabPassword { get; set; } String SabTvCategory { get; set; } SabPriorityType SabRecentTvPriority { get; set; } + SabPriorityType SabOlderTvPriority { get; set; } String DownloadedEpisodesFolder { get; set; } bool UseSeasonFolder { get; set; } string SeasonFolderFormat { get; set; } @@ -39,6 +40,7 @@ namespace NzbDrone.Core.Configuration String NzbgetTvCategory { get; set; } Int32 NzbgetPriority { get; set; } PriorityType NzbgetRecentTvPriority { get; set; } + PriorityType NzbgetOlderTvPriority { get; set; } string ReleaseRestrictions { get; set; } string GetValue(string key, object defaultValue, bool persist = false); void SetValue(string key, string value); diff --git a/NzbDrone.Core/Download/Clients/BlackholeProvider.cs b/NzbDrone.Core/Download/Clients/BlackholeProvider.cs index 7d466411d..43ab97916 100644 --- a/NzbDrone.Core/Download/Clients/BlackholeProvider.cs +++ b/NzbDrone.Core/Download/Clients/BlackholeProvider.cs @@ -32,8 +32,11 @@ namespace NzbDrone.Core.Download.Clients throw new NotImplementedException(); } - public bool DownloadNzb(string url, string title) + public bool DownloadNzb(RemoteEpisode remoteEpisode) { + var url = remoteEpisode.Report.NzbUrl; + var title = remoteEpisode.Report.Title; + try { title = FileNameBuilder.CleanFilename(title); diff --git a/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs b/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs index 48f6e38e3..27a281afc 100644 --- a/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs +++ b/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json; using NLog; using NzbDrone.Common; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Download.Clients.Nzbget { @@ -21,12 +22,15 @@ namespace NzbDrone.Core.Download.Clients.Nzbget _logger = logger; } - public virtual bool DownloadNzb(string url, string title) + public virtual bool DownloadNzb(RemoteEpisode remoteEpisode) { + var url = remoteEpisode.Report.NzbUrl; + var title = remoteEpisode.Report.Title; + try { string cat = _configService.NzbgetTvCategory; - int priority = (int)_configService.NzbgetRecentTvPriority; + int priority = remoteEpisode.IsRecentEpisode() ? (int)_configService.NzbgetRecentTvPriority : (int)_configService.NzbgetOlderTvPriority; var command = new JsonRequest { diff --git a/NzbDrone.Core/Download/Clients/PneumaticClient.cs b/NzbDrone.Core/Download/Clients/PneumaticClient.cs index e77caa049..e66eebbef 100644 --- a/NzbDrone.Core/Download/Clients/PneumaticClient.cs +++ b/NzbDrone.Core/Download/Clients/PneumaticClient.cs @@ -25,12 +25,15 @@ namespace NzbDrone.Core.Download.Clients _diskProvider = diskProvider; } - public virtual bool DownloadNzb(string url, string title) + public virtual bool DownloadNzb(RemoteEpisode remoteEpisode) { + var url = remoteEpisode.Report.NzbUrl; + var title = remoteEpisode.Report.Title; + try { //Todo: Allow full season releases - if (Parser.Parser.ParseTitle(title).FullSeason) + if (remoteEpisode.ParsedEpisodeInfo.FullSeason) { logger.Info("Skipping Full Season Release: {0}", title); return false; diff --git a/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs b/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs index e4aa14b8d..25967ea4a 100644 --- a/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs +++ b/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs @@ -37,7 +37,6 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd return new RestRequest(request); } - private string GetSabRequest(string action) { return string.Format(@"http://{0}:{1}/api?{2}&apikey={3}&ma_username={4}&ma_password={5}", @@ -50,7 +49,6 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd } } - public class SabnzbdClient : IDownloadClient { private readonly IConfigService _configService; @@ -64,12 +62,15 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd _logger = logger; } - public virtual bool DownloadNzb(string url, string title) + public virtual bool DownloadNzb(RemoteEpisode remoteEpisode) { + var url = remoteEpisode.Report.NzbUrl; + var title = remoteEpisode.Report.Title; + try { string cat = _configService.SabTvCategory; - int priority =(int)_configService.SabRecentTvPriority ; + int priority = remoteEpisode.IsRecentEpisode() ? (int)_configService.SabRecentTvPriority : (int)_configService.SabOlderTvPriority; string name = url.Replace("&", "%26"); string nzbName = HttpUtility.UrlEncode(title); diff --git a/NzbDrone.Core/Download/DownloadService.cs b/NzbDrone.Core/Download/DownloadService.cs index e5565fe09..9eb0b82c4 100644 --- a/NzbDrone.Core/Download/DownloadService.cs +++ b/NzbDrone.Core/Download/DownloadService.cs @@ -27,10 +27,9 @@ namespace NzbDrone.Core.Download public bool DownloadReport(RemoteEpisode remoteEpisode) { var downloadTitle = remoteEpisode.Report.Title; - var provider = _downloadClientProvider.GetDownloadClient(); - bool success = provider.DownloadNzb(remoteEpisode.Report.NzbUrl, downloadTitle); + bool success = provider.DownloadNzb(remoteEpisode); if (success) { @@ -40,7 +39,5 @@ namespace NzbDrone.Core.Download return success; } - - } } \ No newline at end of file diff --git a/NzbDrone.Core/Download/IDownloadClient.cs b/NzbDrone.Core/Download/IDownloadClient.cs index 728c81046..8e2cdebae 100644 --- a/NzbDrone.Core/Download/IDownloadClient.cs +++ b/NzbDrone.Core/Download/IDownloadClient.cs @@ -1,12 +1,13 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Core.Model; +using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.Download { public interface IDownloadClient { - bool DownloadNzb(string url, string title); + bool DownloadNzb(RemoteEpisode remoteEpisode); IEnumerable GetQueue(); } diff --git a/NzbDrone.Core/Parser/Model/RemoteEpisode.cs b/NzbDrone.Core/Parser/Model/RemoteEpisode.cs index 4ff6ad16e..703d6fae3 100644 --- a/NzbDrone.Core/Parser/Model/RemoteEpisode.cs +++ b/NzbDrone.Core/Parser/Model/RemoteEpisode.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Linq; using NzbDrone.Core.Tv; namespace NzbDrone.Core.Parser.Model @@ -12,5 +14,10 @@ namespace NzbDrone.Core.Parser.Model public Series Series { get; set; } public List Episodes { get; set; } + + public bool IsRecentEpisode() + { + return Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-14)); + } } } \ No newline at end of file diff --git a/UI/Settings/DownloadClient/NzbgetViewTemplate.html b/UI/Settings/DownloadClient/NzbgetViewTemplate.html index 21b38dd3d..809c4492a 100644 --- a/UI/Settings/DownloadClient/NzbgetViewTemplate.html +++ b/UI/Settings/DownloadClient/NzbgetViewTemplate.html @@ -47,6 +47,7 @@ +
@@ -60,7 +61,25 @@ - + + +
+ + +
+ + +
+ + +
diff --git a/UI/Settings/DownloadClient/SabViewTemplate.html b/UI/Settings/DownloadClient/SabViewTemplate.html index 0601fdc50..d25b98d9e 100644 --- a/UI/Settings/DownloadClient/SabViewTemplate.html +++ b/UI/Settings/DownloadClient/SabViewTemplate.html @@ -61,7 +61,6 @@ -
@@ -75,7 +74,25 @@ - + + +
+ + +
+ + +
+ + +