Episodes older than 14 days have their own priority

pull/4/head
Mark McDowall 11 years ago
parent c12ea363d8
commit 98e94643fb

@ -6,6 +6,7 @@ using NUnit.Framework;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients; using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
@ -14,21 +15,26 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
[TestFixture] [TestFixture]
public class BlackholeProviderFixture : CoreTest<BlackholeProvider> public class BlackholeProviderFixture : CoreTest<BlackholeProvider>
{ {
private const string nzbUrl = "http://www.nzbs.com/url"; private const string _nzbUrl = "http://www.nzbs.com/url";
private const string title = "some_nzb_title"; private const string _title = "some_nzb_title";
private const string blackHoleFolder = @"d:\nzb\blackhole\"; private const string _blackHoleFolder = @"d:\nzb\blackhole\";
private const string nzbPath = @"d:\nzb\blackhole\some_nzb_title.nzb"; private const string _nzbPath = @"d:\nzb\blackhole\some_nzb_title.nzb";
private RemoteEpisode _remoteEpisode;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
Mocker.GetMock<IConfigService>().SetupGet(c => c.BlackholeFolder).Returns(blackHoleFolder); Mocker.GetMock<IConfigService>().SetupGet(c => c.BlackholeFolder).Returns(_blackHoleFolder);
}
_remoteEpisode = new RemoteEpisode();
_remoteEpisode.Report = new ReportInfo();
_remoteEpisode.Report.Title = _title;
_remoteEpisode.Report.NzbUrl = _nzbUrl;
}
private void WithExistingFile() private void WithExistingFile()
{ {
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(nzbPath)).Returns(true); Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(_nzbPath)).Returns(true);
} }
private void WithFailedDownload() private void WithFailedDownload()
@ -39,9 +45,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
[Test] [Test]
public void DownloadNzb_should_download_file_if_it_doesnt_exist() public void DownloadNzb_should_download_file_if_it_doesnt_exist()
{ {
Subject.DownloadNzb(nzbUrl, title).Should().BeTrue(); Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(nzbUrl, nzbPath), Times.Once()); Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath), Times.Once());
} }
[Test] [Test]
@ -49,7 +55,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
{ {
WithExistingFile(); WithExistingFile();
Subject.DownloadNzb(nzbUrl, title).Should().BeTrue(); Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never()); Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
} }
@ -59,7 +65,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
{ {
WithFailedDownload(); WithFailedDownload();
Subject.DownloadNzb(nzbUrl, title).Should().BeFalse(); Subject.DownloadNzb(_remoteEpisode).Should().BeFalse();
ExceptionVerification.ExpectedWarns(1); ExceptionVerification.ExpectedWarns(1);
} }
@ -68,9 +74,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
public void should_replace_illegal_characters_in_title() public void should_replace_illegal_characters_in_title()
{ {
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]"; 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<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once()); Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
} }

@ -5,12 +5,17 @@ using NUnit.Framework;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.Nzbget; using NzbDrone.Core.Download.Clients.Nzbget;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
{ {
public class DownloadNzbFixture : CoreTest 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] [SetUp]
public void 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.NzbgetPassword).Returns("pass");
fakeConfig.SetupGet(c => c.NzbgetTvCategory).Returns("TV"); fakeConfig.SetupGet(c => c.NzbgetTvCategory).Returns("TV");
fakeConfig.SetupGet(c => c.NzbgetRecentTvPriority).Returns(PriorityType.High); 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() private void WithFailResponse()
{ {
@ -34,16 +43,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
[Test] [Test]
public void should_add_item_to_queue() 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<IHttpProvider>() Mocker.GetMock<IHttpProvider>()
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", .Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass",
It.Is<String>(c => c.Equals("{\"method\":\"appendurl\",\"params\":[\"30 Rock - S01E01 - Pilot [HDTV-720p]\",\"TV\",50,false,\"http://www.nzbdrone.com\"]}")))) It.Is<String>(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}"); .Returns("{\"version\": \"1.1\",\"result\": true}");
Mocker.Resolve<NzbgetClient>() Mocker.Resolve<NzbgetClient>()
.DownloadNzb(url, title) .DownloadNzb(_remoteEpisode)
.Should() .Should()
.BeTrue(); .BeTrue();
} }
@ -53,7 +59,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
{ {
WithFailResponse(); WithFailResponse();
Assert.Throws<ApplicationException>(() => Mocker.Resolve<NzbgetClient>().DownloadNzb("http://www.nzbdrone.com", "30 Rock - S01E01 - Pilot [HDTV-720p]")); Assert.Throws<ApplicationException>(() => Mocker.Resolve<NzbgetClient>().DownloadNzb(_remoteEpisode));
} }
} }
} }

@ -6,32 +6,42 @@ using NUnit.Framework;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients; using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.Download.DownloadClientTests namespace NzbDrone.Core.Test.Download.DownloadClientTests
{ {
[TestFixture] [TestFixture]
public class PneumaticProviderFixture : CoreTest public class PneumaticProviderFixture : CoreTest<PneumaticClient>
{ {
private const string nzbUrl = "http://www.nzbs.com/url"; private const string _nzbUrl = "http://www.nzbs.com/url";
private const string title = "30.Rock.S01E05.hdtv.xvid-LoL"; private const string _title = "30.Rock.S01E05.hdtv.xvid-LoL";
private const string pneumaticFolder = @"d:\nzb\pneumatic\"; private const string _pneumaticFolder = @"d:\nzb\pneumatic\";
private const string sabDrop = @"d:\unsorted tv\"; private const string _sabDrop = @"d:\unsorted tv\";
private string nzbPath; private string _nzbPath;
private RemoteEpisode _remoteEpisode;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
nzbPath = pneumaticFolder + title + ".nzb"; _nzbPath = _pneumaticFolder + _title + ".nzb";
Mocker.GetMock<IConfigService>().SetupGet(c => c.PneumaticFolder).Returns(pneumaticFolder); Mocker.GetMock<IConfigService>().SetupGet(c => c.PneumaticFolder).Returns(_pneumaticFolder);
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedEpisodesFolder).Returns(sabDrop); Mocker.GetMock<IConfigService>().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() private void WithExistingFile()
{ {
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(nzbPath)).Returns(true); Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(_nzbPath)).Returns(true);
} }
private void WithFailedDownload() private void WithFailedDownload()
@ -42,9 +52,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
[Test] [Test]
public void should_download_file_if_it_doesnt_exist() public void should_download_file_if_it_doesnt_exist()
{ {
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, title).Should().BeTrue(); Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(nzbUrl, nzbPath),Times.Once()); Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath),Times.Once());
} }
[Test] [Test]
@ -52,7 +62,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
{ {
WithExistingFile(); WithExistingFile();
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, title).Should().BeTrue(); Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never()); Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
} }
@ -62,7 +72,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
{ {
WithFailedDownload(); WithFailedDownload();
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, title).Should().BeFalse(); Subject.DownloadNzb(_remoteEpisode).Should().BeFalse();
ExceptionVerification.ExpectedWarns(1); ExceptionVerification.ExpectedWarns(1);
} }
@ -70,16 +80,20 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
[Test] [Test]
public void should_skip_if_full_season_download() public void should_skip_if_full_season_download()
{ {
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, "30 Rock - Season 1").Should().BeFalse(); _remoteEpisode.Report.Title = "30 Rock - Season 1";
_remoteEpisode.ParsedEpisodeInfo.FullSeason = true;
Mocker.Resolve<PneumaticClient>().DownloadNzb(_remoteEpisode).Should().BeFalse();
} }
[Test] [Test]
public void should_replace_illegal_characters_in_title() public void should_replace_illegal_characters_in_title()
{ {
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]"; 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<PneumaticClient>().DownloadNzb(nzbUrl, illegalTitle).Should().BeTrue(); Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once()); Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
} }

@ -6,6 +6,7 @@ using NUnit.Framework;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.Sabnzbd; using NzbDrone.Core.Download.Clients.Sabnzbd;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common; 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 URL = "http://www.nzbclub.com/nzb_download.aspx?mid=1950232";
private const string TITLE = "My Series Name - 5x2-5x3 - My title [Bluray720p] [Proper]"; private const string TITLE = "My Series Name - 5x2-5x3 - My title [Bluray720p] [Proper]";
private RemoteEpisode _remoteEpisode;
[SetUp] [SetUp]
public void 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.SabUsername).Returns("admin");
fakeConfig.SetupGet(c => c.SabPassword).Returns("pass"); fakeConfig.SetupGet(c => c.SabPassword).Returns("pass");
fakeConfig.SetupGet(c => c.SabTvCategory).Returns("tv"); 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() private void WithFailResponse()
@ -45,14 +52,14 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
.Returns("{ \"status\": true }"); .Returns("{ \"status\": true }");
Subject.DownloadNzb(URL, TITLE).Should().BeTrue(); Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
} }
[Test] [Test]
public void add_by_url_should_detect_and_handle_sab_errors() public void add_by_url_should_detect_and_handle_sab_errors()
{ {
WithFailResponse(); WithFailResponse();
Assert.Throws<ApplicationException>(() => Subject.DownloadNzb(URL, TITLE).Should().BeFalse()); Assert.Throws<ApplicationException>(() => Subject.DownloadNzb(_remoteEpisode).Should().BeFalse());
} }
[Test] [Test]
@ -186,7 +193,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
Mocker.GetMock<IHttpProvider>() Mocker.GetMock<IHttpProvider>()
.Setup(s => s.DownloadString(It.IsAny<String>())).Throws(new WebException()); .Setup(s => s.DownloadString(It.IsAny<String>())).Throws(new WebException());
Subject.DownloadNzb(URL, TITLE).Should().BeFalse(); Subject.DownloadNzb(_remoteEpisode).Should().BeFalse();
ExceptionVerification.ExpectedErrors(1); ExceptionVerification.ExpectedErrors(1);
} }
@ -203,11 +210,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
.Returns("{ \"status\": true }"); .Returns("{ \"status\": true }");
Subject.DownloadNzb(URL, TITLE).Should().BeTrue(); Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
Mocker.GetMock<IHttpProvider>() Mocker.GetMock<IHttpProvider>()
.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()); .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());
} }
} }
} }

@ -37,14 +37,14 @@ namespace NzbDrone.Core.Test.Download
private void WithSuccessfulAdd() private void WithSuccessfulAdd()
{ {
Mocker.GetMock<IDownloadClient>() Mocker.GetMock<IDownloadClient>()
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>())) .Setup(s => s.DownloadNzb(It.IsAny<RemoteEpisode>()))
.Returns(true); .Returns(true);
} }
private void WithFailedAdd() private void WithFailedAdd()
{ {
Mocker.GetMock<IDownloadClient>() Mocker.GetMock<IDownloadClient>()
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>())) .Setup(s => s.DownloadNzb(It.IsAny<RemoteEpisode>()))
.Returns(false); .Returns(false);
} }
@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.Download
Subject.DownloadReport(_parseResult); Subject.DownloadReport(_parseResult);
Mocker.GetMock<IDownloadClient>() Mocker.GetMock<IDownloadClient>()
.Verify(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>()), Times.Once()); .Verify(s => s.DownloadNzb(It.IsAny<RemoteEpisode>()), Times.Once());
} }
[Test] [Test]
@ -77,8 +77,5 @@ namespace NzbDrone.Core.Test.Download
Subject.DownloadReport(_parseResult); Subject.DownloadReport(_parseResult);
VerifyEventNotPublished<EpisodeGrabbedEvent>(); VerifyEventNotPublished<EpisodeGrabbedEvent>();
} }
} }
} }

@ -109,6 +109,13 @@ namespace NzbDrone.Core.Configuration
set { SetValue("SabRecentTvPriority", value); } set { SetValue("SabRecentTvPriority", value); }
} }
public SabPriorityType SabOlderTvPriority
{
get { return GetValueEnum("SabOlderTvPriority", SabPriorityType.Default); }
set { SetValue("SabOlderTvPriority", value); }
}
public String DownloadedEpisodesFolder public String DownloadedEpisodesFolder
{ {
get { return GetValue("DownloadedEpisodesFolder"); } get { return GetValue("DownloadedEpisodesFolder"); }
@ -251,6 +258,13 @@ namespace NzbDrone.Core.Configuration
set { SetValue("NzbgetRecentTvPriority", value); } set { SetValue("NzbgetRecentTvPriority", value); }
} }
public PriorityType NzbgetOlderTvPriority
{
get { return GetValueEnum("NzbgetOlderTvPriority", PriorityType.Normal); }
set { SetValue("NzbgetOlderTvPriority", value); }
}
public string ReleaseRestrictions public string ReleaseRestrictions
{ {
get { return GetValue("ReleaseRestrictions", String.Empty); } get { return GetValue("ReleaseRestrictions", String.Empty); }

@ -18,6 +18,7 @@ namespace NzbDrone.Core.Configuration
String SabPassword { get; set; } String SabPassword { get; set; }
String SabTvCategory { get; set; } String SabTvCategory { get; set; }
SabPriorityType SabRecentTvPriority { get; set; } SabPriorityType SabRecentTvPriority { get; set; }
SabPriorityType SabOlderTvPriority { get; set; }
String DownloadedEpisodesFolder { get; set; } String DownloadedEpisodesFolder { get; set; }
bool UseSeasonFolder { get; set; } bool UseSeasonFolder { get; set; }
string SeasonFolderFormat { get; set; } string SeasonFolderFormat { get; set; }
@ -39,6 +40,7 @@ namespace NzbDrone.Core.Configuration
String NzbgetTvCategory { get; set; } String NzbgetTvCategory { get; set; }
Int32 NzbgetPriority { get; set; } Int32 NzbgetPriority { get; set; }
PriorityType NzbgetRecentTvPriority { get; set; } PriorityType NzbgetRecentTvPriority { get; set; }
PriorityType NzbgetOlderTvPriority { get; set; }
string ReleaseRestrictions { get; set; } string ReleaseRestrictions { get; set; }
string GetValue(string key, object defaultValue, bool persist = false); string GetValue(string key, object defaultValue, bool persist = false);
void SetValue(string key, string value); void SetValue(string key, string value);

@ -32,8 +32,11 @@ namespace NzbDrone.Core.Download.Clients
throw new NotImplementedException(); 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 try
{ {
title = FileNameBuilder.CleanFilename(title); title = FileNameBuilder.CleanFilename(title);

@ -5,6 +5,7 @@ using Newtonsoft.Json;
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Download.Clients.Nzbget namespace NzbDrone.Core.Download.Clients.Nzbget
{ {
@ -21,12 +22,15 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
_logger = logger; _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 try
{ {
string cat = _configService.NzbgetTvCategory; string cat = _configService.NzbgetTvCategory;
int priority = (int)_configService.NzbgetRecentTvPriority; int priority = remoteEpisode.IsRecentEpisode() ? (int)_configService.NzbgetRecentTvPriority : (int)_configService.NzbgetOlderTvPriority;
var command = new JsonRequest var command = new JsonRequest
{ {

@ -25,12 +25,15 @@ namespace NzbDrone.Core.Download.Clients
_diskProvider = diskProvider; _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 try
{ {
//Todo: Allow full season releases //Todo: Allow full season releases
if (Parser.Parser.ParseTitle(title).FullSeason) if (remoteEpisode.ParsedEpisodeInfo.FullSeason)
{ {
logger.Info("Skipping Full Season Release: {0}", title); logger.Info("Skipping Full Season Release: {0}", title);
return false; return false;

@ -37,7 +37,6 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
return new RestRequest(request); return new RestRequest(request);
} }
private string GetSabRequest(string action) private string GetSabRequest(string action)
{ {
return string.Format(@"http://{0}:{1}/api?{2}&apikey={3}&ma_username={4}&ma_password={5}", 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 public class SabnzbdClient : IDownloadClient
{ {
private readonly IConfigService _configService; private readonly IConfigService _configService;
@ -64,12 +62,15 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
_logger = logger; _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 try
{ {
string cat = _configService.SabTvCategory; 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 name = url.Replace("&", "%26");
string nzbName = HttpUtility.UrlEncode(title); string nzbName = HttpUtility.UrlEncode(title);

@ -27,10 +27,9 @@ namespace NzbDrone.Core.Download
public bool DownloadReport(RemoteEpisode remoteEpisode) public bool DownloadReport(RemoteEpisode remoteEpisode)
{ {
var downloadTitle = remoteEpisode.Report.Title; var downloadTitle = remoteEpisode.Report.Title;
var provider = _downloadClientProvider.GetDownloadClient(); var provider = _downloadClientProvider.GetDownloadClient();
bool success = provider.DownloadNzb(remoteEpisode.Report.NzbUrl, downloadTitle); bool success = provider.DownloadNzb(remoteEpisode);
if (success) if (success)
{ {
@ -40,7 +39,5 @@ namespace NzbDrone.Core.Download
return success; return success;
} }
} }
} }

@ -1,12 +1,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Download namespace NzbDrone.Core.Download
{ {
public interface IDownloadClient public interface IDownloadClient
{ {
bool DownloadNzb(string url, string title); bool DownloadNzb(RemoteEpisode remoteEpisode);
IEnumerable<QueueItem> GetQueue(); IEnumerable<QueueItem> GetQueue();
} }

@ -1,4 +1,6 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Parser.Model namespace NzbDrone.Core.Parser.Model
@ -12,5 +14,10 @@ namespace NzbDrone.Core.Parser.Model
public Series Series { get; set; } public Series Series { get; set; }
public List<Episode> Episodes { get; set; } public List<Episode> Episodes { get; set; }
public bool IsRecentEpisode()
{
return Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-14));
}
} }
} }

@ -47,6 +47,7 @@
<input type="text" name="nzbgetTvCategory"/> <input type="text" name="nzbgetTvCategory"/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label">Download Priority</label> <label class="control-label">Download Priority</label>
@ -60,7 +61,25 @@
<option value="force">Force</option> <option value="force">Force</option>
</select> </select>
<span class="help-inline"> <span class="help-inline">
<i class="icon-form-info" title="Priority to use when sending episodes that aired within the last 7 days to NZBGet"/> <i class="icon-form-info" title="Priority to use when sending episodes that aired within the last 14 days to NZBGet"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Older Download Priority</label>
<div class="controls">
<select name="nzbgetOlderTvPriority">
<option value="default">Default</option>
<option value="pasued">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-form-info" title="Priority to use when sending episodes that aired prior to 14 days to NZBGet"/>
</span> </span>
</div> </div>
</div> </div>

@ -61,7 +61,6 @@
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label">Download Priority</label> <label class="control-label">Download Priority</label>
@ -75,7 +74,25 @@
<option value="force">Force</option> <option value="force">Force</option>
</select> </select>
<span class="help-inline"> <span class="help-inline">
<i class="icon-form-info" title="Priority to use when sending episodes that aired within the last 7 days to SABnzbd"/> <i class="icon-form-info" title="Priority to use when sending episodes that aired within the last 14 days to SABnzbd"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Older Download Priority</label>
<div class="controls">
<select name="sabOlderTvPriority">
<option value="default">Default</option>
<option value="paused">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-form-info" title="Priority to use when sending episodes that aired prior to 14 days to SABnzbd"/>
</span> </span>
</div> </div>
</div> </div>

Loading…
Cancel
Save