mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Episodes older than 14 days have their own priority
This commit is contained in:
parent
c12ea363d8
commit
98e94643fb
@ -6,6 +6,7 @@
|
||||
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<BlackholeProvider>
|
||||
{
|
||||
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<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()
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(nzbPath)).Returns(true);
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(_nzbPath)).Returns(true);
|
||||
}
|
||||
|
||||
private void WithFailedDownload()
|
||||
@ -39,9 +45,9 @@ private void WithFailedDownload()
|
||||
[Test]
|
||||
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]
|
||||
@ -49,7 +55,7 @@ public void DownloadNzb_not_download_file_if_it_doesn_exist()
|
||||
{
|
||||
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());
|
||||
}
|
||||
@ -59,7 +65,7 @@ public void should_return_false_on_failed_download()
|
||||
{
|
||||
WithFailedDownload();
|
||||
|
||||
Subject.DownloadNzb(nzbUrl, title).Should().BeFalse();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeFalse();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
@ -68,9 +74,10 @@ public void should_return_false_on_failed_download()
|
||||
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<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
|
||||
}
|
||||
|
@ -5,12 +5,17 @@
|
||||
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 @@ public void Setup()
|
||||
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 @@ private void WithFailResponse()
|
||||
[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<IHttpProvider>()
|
||||
.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\"]}"))))
|
||||
.Returns("{\"version\": \"1.1\",\"result\": true}");
|
||||
|
||||
Mocker.Resolve<NzbgetClient>()
|
||||
.DownloadNzb(url, title)
|
||||
.DownloadNzb(_remoteEpisode)
|
||||
.Should()
|
||||
.BeTrue();
|
||||
}
|
||||
@ -53,7 +59,7 @@ public void should_throw_when_error_is_returned()
|
||||
{
|
||||
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 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<PneumaticClient>
|
||||
{
|
||||
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<IConfigService>().SetupGet(c => c.PneumaticFolder).Returns(pneumaticFolder);
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedEpisodesFolder).Returns(sabDrop);
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.PneumaticFolder).Returns(_pneumaticFolder);
|
||||
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()
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(nzbPath)).Returns(true);
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(_nzbPath)).Returns(true);
|
||||
}
|
||||
|
||||
private void WithFailedDownload()
|
||||
@ -42,9 +52,9 @@ private void WithFailedDownload()
|
||||
[Test]
|
||||
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]
|
||||
@ -52,7 +62,7 @@ public void should_not_download_file_if_it_doesn_exist()
|
||||
{
|
||||
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());
|
||||
}
|
||||
@ -62,7 +72,7 @@ public void should_return_false_on_failed_download()
|
||||
{
|
||||
WithFailedDownload();
|
||||
|
||||
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, title).Should().BeFalse();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeFalse();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
@ -70,16 +80,20 @@ public void should_return_false_on_failed_download()
|
||||
[Test]
|
||||
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]
|
||||
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<PneumaticClient>().DownloadNzb(nzbUrl, illegalTitle).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
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 @@ public class SabProviderFixture : CoreTest<SabnzbdClient>
|
||||
{
|
||||
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 @@ public void Setup()
|
||||
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 @@ public void add_url_should_format_request_properly()
|
||||
.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<ApplicationException>(() => Subject.DownloadNzb(URL, TITLE).Should().BeFalse());
|
||||
Assert.Throws<ApplicationException>(() => Subject.DownloadNzb(_remoteEpisode).Should().BeFalse());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -186,7 +193,7 @@ public void should_return_false_when_WebException_is_thrown()
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.DownloadString(It.IsAny<String>())).Throws(new WebException());
|
||||
|
||||
Subject.DownloadNzb(URL, TITLE).Should().BeFalse();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeFalse();
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
@ -203,11 +210,10 @@ public void downloadNzb_should_use_sabRecentTvPriority_when_recentEpisode_is_tru
|
||||
.Returns("{ \"status\": true }");
|
||||
|
||||
|
||||
Subject.DownloadNzb(URL, TITLE).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,14 +37,14 @@ public void Setup()
|
||||
private void WithSuccessfulAdd()
|
||||
{
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>()))
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<RemoteEpisode>()))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
private void WithFailedAdd()
|
||||
{
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>()))
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<RemoteEpisode>()))
|
||||
.Returns(false);
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ public void Download_report_should_grab_using_client()
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
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]
|
||||
@ -77,8 +77,5 @@ public void Download_report_should_not_publish_on_failed_grab_event()
|
||||
Subject.DownloadReport(_parseResult);
|
||||
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,13 @@ public SabPriorityType SabRecentTvPriority
|
||||
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 @@ public PriorityType NzbgetRecentTvPriority
|
||||
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); }
|
||||
|
@ -18,6 +18,7 @@ public interface IConfigService
|
||||
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 @@ public interface IConfigService
|
||||
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);
|
||||
|
@ -32,8 +32,11 @@ public bool IsInQueue(RemoteEpisode newEpisode)
|
||||
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);
|
||||
|
@ -5,6 +5,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
{
|
||||
@ -21,12 +22,15 @@ public NzbgetClient(IConfigService configService, IHttpProvider httpProvider, Lo
|
||||
_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
|
||||
{
|
||||
|
@ -25,12 +25,15 @@ public PneumaticClient(IConfigService configService, IHttpProvider httpProvider,
|
||||
_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;
|
||||
|
@ -37,7 +37,6 @@ public IRestRequest AddToQueueRequest(RemoteEpisode remoteEpisode)
|
||||
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 @@ private string GetSabRequest(string action)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SabnzbdClient : IDownloadClient
|
||||
{
|
||||
private readonly IConfigService _configService;
|
||||
@ -64,12 +62,15 @@ public SabnzbdClient(IConfigService configService, IHttpProvider httpProvider, L
|
||||
_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);
|
||||
|
@ -27,10 +27,9 @@ public DownloadService(IProvideDownloadClient downloadClientProvider,
|
||||
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 @@ public bool DownloadReport(RemoteEpisode remoteEpisode)
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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<QueueItem> GetQueue();
|
||||
}
|
||||
|
||||
|
@ -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 @@ public class RemoteEpisode
|
||||
public Series Series { 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"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Download Priority</label>
|
||||
|
||||
@ -60,7 +61,25 @@
|
||||
<option value="force">Force</option>
|
||||
</select>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -61,7 +61,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Download Priority</label>
|
||||
|
||||
@ -75,7 +74,25 @@
|
||||
<option value="force">Force</option>
|
||||
</select>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user