Download decision rejection reasons are no longer static messages

New: Better messaging on manual search when release is rejected
pull/128/head
Mark McDowall 10 years ago
parent e82b29e346
commit 95d67ef9f4

@ -0,0 +1,20 @@
using System;
namespace NzbDrone.Common.Extensions
{
public static class Int64Extensions
{
private static readonly string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
public static string SizeSuffix(this Int64 value)
{
if (value < 0) { return "-" + SizeSuffix(-value); }
if (value == 0) { return "0.0 bytes"; }
var mag = (int)Math.Log(value, 1024);
decimal adjustedSize = (decimal)value / (1L << (mag * 10));
return string.Format("{0:n1} {1}", adjustedSize, SizeSuffixes[mag]);
}
}
}

@ -125,6 +125,7 @@
<Compile Include="Expansive\TreeNode.cs" /> <Compile Include="Expansive\TreeNode.cs" />
<Compile Include="Expansive\TreeNodeList.cs" /> <Compile Include="Expansive\TreeNodeList.cs" />
<Compile Include="Extensions\Base64Extentions.cs" /> <Compile Include="Extensions\Base64Extentions.cs" />
<Compile Include="Extensions\Int64Extensions.cs" />
<Compile Include="Extensions\StreamExtensions.cs" /> <Compile Include="Extensions\StreamExtensions.cs" />
<Compile Include="HashUtil.cs" /> <Compile Include="HashUtil.cs" />
<Compile Include="Http\GZipWebClient.cs"> <Compile Include="Http\GZipWebClient.cs">

@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
parseResultSingle.Series = series; parseResultSingle.Series = series;
parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes(); parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes();
Subject.IsSatisfiedBy(parseResultSingle, null).Should().Be(expectedResult); Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult);
} }
[TestCase(30, 500, true)] [TestCase(30, 500, true)]
@ -103,7 +103,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
parseResultSingle.Series = series; parseResultSingle.Series = series;
parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes(); parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes();
Subject.IsSatisfiedBy(parseResultSingle, null).Should().Be(expectedResult); Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult);
} }
[TestCase(30, 50 * 2, false)] [TestCase(30, 50 * 2, false)]
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
parseResultMulti.Series = series; parseResultMulti.Series = series;
parseResultMulti.Release.Size = sizeInMegaBytes.Megabytes(); parseResultMulti.Release.Size = sizeInMegaBytes.Megabytes();
Subject.IsSatisfiedBy(parseResultMulti, null).Should().Be(expectedResult); Subject.IsSatisfiedBy(parseResultMulti, null).Accepted.Should().Be(expectedResult);
} }
[TestCase(30, 50 * 6, false)] [TestCase(30, 50 * 6, false)]
@ -133,7 +133,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
parseResultMultiSet.Series = series; parseResultMultiSet.Series = series;
parseResultMultiSet.Release.Size = sizeInMegaBytes.Megabytes(); parseResultMultiSet.Release.Size = sizeInMegaBytes.Megabytes();
Subject.IsSatisfiedBy(parseResultMultiSet, null).Should().Be(expectedResult); Subject.IsSatisfiedBy(parseResultMultiSet, null).Accepted.Should().Be(expectedResult);
} }
[Test] [Test]
@ -146,7 +146,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
parseResultSingle.Release.Size = 18457280000; parseResultSingle.Release.Size = 18457280000;
qualityType.MaxSize = 0; qualityType.MaxSize = 0;
Subject.IsSatisfiedBy(parseResultSingle, null).Should().BeTrue(); Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -159,7 +159,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
parseResultSingle.Release.Size = 36857280000; parseResultSingle.Release.Size = 36857280000;
qualityType.MaxSize = 0; qualityType.MaxSize = 0;
Subject.IsSatisfiedBy(parseResultSingle, null).Should().BeTrue();; Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); ;
} }
[Test] [Test]
@ -174,7 +174,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
qualityType.MaxSize = 10; qualityType.MaxSize = 10;
Subject.IsSatisfiedBy(parseResultSingle, null).Should().BeTrue(); Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -185,18 +185,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.RAWHD) }, ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.RAWHD) },
}; };
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue(); Subject.IsSatisfiedBy(parseResult, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void should_always_return_false_if_unknown() public void should_return_true_if_unknown()
{ {
var parseResult = new RemoteEpisode var parseResult = new RemoteEpisode
{ {
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.Unknown) }, ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.Unknown) },
}; };
Subject.IsSatisfiedBy(parseResult, null).Should().BeFalse(); Subject.IsSatisfiedBy(parseResult, null).Accepted.Should().BeTrue();
Mocker.GetMock<IQualityDefinitionService>().Verify(c => c.Get(It.IsAny<Quality>()), Times.Never()); Mocker.GetMock<IQualityDefinitionService>().Verify(c => c.Get(It.IsAny<Quality>()), Times.Never());
} }

@ -63,21 +63,21 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
_remoteEpisode.Episodes.First().EpisodeFileId = 0; _remoteEpisode.Episodes.First().EpisodeFileId = 0;
_subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void should_be_true_if_series_is_not_anime() public void should_be_true_if_series_is_not_anime()
{ {
GivenStandardSeries(); GivenStandardSeries();
_subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void should_be_true_if_is_not_a_version_upgrade_for_existing_file() public void should_be_true_if_is_not_a_version_upgrade_for_existing_file()
{ {
GivenNoVersionUpgrade(); GivenNoVersionUpgrade();
_subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -85,27 +85,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
_episodeFile.ReleaseGroup = _remoteEpisode.ParsedEpisodeInfo.ReleaseGroup; _episodeFile.ReleaseGroup = _remoteEpisode.ParsedEpisodeInfo.ReleaseGroup;
_subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void should_be_false_when_existing_file_doesnt_have_a_release_group() public void should_be_false_when_existing_file_doesnt_have_a_release_group()
{ {
_episodeFile.ReleaseGroup = String.Empty; _episodeFile.ReleaseGroup = String.Empty;
_subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
public void should_should_be_false_when_release_doesnt_have_a_release_group() public void should_should_be_false_when_release_doesnt_have_a_release_group()
{ {
_remoteEpisode.ParsedEpisodeInfo.ReleaseGroup = String.Empty; _remoteEpisode.ParsedEpisodeInfo.ReleaseGroup = String.Empty;
_subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
public void should_be_false_when_release_group_does_not_match() public void should_be_false_when_release_group_does_not_match()
{ {
_subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
} }
} }

@ -39,24 +39,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_fail2 = new Mock<IDecisionEngineSpecification>(); _fail2 = new Mock<IDecisionEngineSpecification>();
_fail3 = new Mock<IDecisionEngineSpecification>(); _fail3 = new Mock<IDecisionEngineSpecification>();
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(true); _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(Decision.Accept);
_pass1.Setup(c => c.RejectionReason).Returns("_pass1"); _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(Decision.Accept);
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(Decision.Accept);
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(true); _fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(Decision.Reject("fail1"));
_pass2.Setup(c => c.RejectionReason).Returns("_pass2"); _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(Decision.Reject("fail2"));
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(Decision.Reject("fail3"));
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(true);
_pass3.Setup(c => c.RejectionReason).Returns("_pass3");
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(false);
_fail1.Setup(c => c.RejectionReason).Returns("_fail1");
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(false);
_fail2.Setup(c => c.RejectionReason).Returns("_fail2");
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null)).Returns(false);
_fail3.Setup(c => c.RejectionReason).Returns("_fail3");
_reports = new List<ReleaseInfo> { new ReleaseInfo { Title = "The.Office.S03E115.DVDRip.XviD-OSiTV" } }; _reports = new List<ReleaseInfo> { new ReleaseInfo { Title = "The.Office.S03E115.DVDRip.XviD-OSiTV" } };
_remoteEpisode = new RemoteEpisode { Series = new Series() }; _remoteEpisode = new RemoteEpisode { Series = new Series() };

@ -99,7 +99,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_be_upgradable_if_only_episode_is_upgradable() public void should_be_upgradable_if_only_episode_is_upgradable()
{ {
WithFirstReportUpgradable(); WithFirstReportUpgradable();
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Should().BeTrue(); _upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -107,27 +107,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
WithFirstReportUpgradable(); WithFirstReportUpgradable();
WithSecondReportUpgradable(); WithSecondReportUpgradable();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue(); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void should_not_be_upgradable_if_both_episodes_are_not_upgradable() public void should_not_be_upgradable_if_both_episodes_are_not_upgradable()
{ {
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
public void should_be_not_upgradable_if_only_first_episodes_is_upgradable() public void should_be_not_upgradable_if_only_first_episodes_is_upgradable()
{ {
WithFirstReportUpgradable(); WithFirstReportUpgradable();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
public void should_be_not_upgradable_if_only_second_episodes_is_upgradable() public void should_be_not_upgradable_if_only_second_episodes_is_upgradable()
{ {
WithSecondReportUpgradable(); WithSecondReportUpgradable();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -139,13 +139,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<Profile>(), 1)).Returns(_upgradableQuality); Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(It.IsAny<Profile>(), 1)).Returns(_upgradableQuality);
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse(); _upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
public void should_return_true_if_it_is_a_search() public void should_return_true_if_it_is_a_search()
{ {
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Should().BeTrue(); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -153,7 +153,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
GivenSabnzbdDownloadClient(); GivenSabnzbdDownloadClient();
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue(); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -162,7 +162,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
GivenSabnzbdDownloadClient(); GivenSabnzbdDownloadClient();
GivenMostRecentForEpisode(HistoryEventType.Grabbed); GivenMostRecentForEpisode(HistoryEventType.Grabbed);
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -171,7 +171,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
GivenSabnzbdDownloadClient(); GivenSabnzbdDownloadClient();
GivenMostRecentForEpisode(HistoryEventType.DownloadFailed); GivenMostRecentForEpisode(HistoryEventType.DownloadFailed);
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue(); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -180,7 +180,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
GivenSabnzbdDownloadClient(); GivenSabnzbdDownloadClient();
GivenMostRecentForEpisode(HistoryEventType.DownloadFolderImported); GivenMostRecentForEpisode(HistoryEventType.DownloadFolderImported);
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue(); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
} }
} }
} }

@ -50,7 +50,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
WithEnglishRelease(); WithEnglishRelease();
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
WithGermanRelease(); WithGermanRelease();
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
} }
} }

@ -64,22 +64,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test] [Test]
public void setup_should_return_monitored_episode_should_return_true() public void setup_should_return_monitored_episode_should_return_true()
{ {
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Should().BeTrue(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void not_monitored_series_should_be_skipped() public void not_monitored_series_should_be_skipped()
{ {
_fakeSeries.Monitored = false; _fakeSeries.Monitored = false;
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
public void only_episode_not_monitored_should_return_false() public void only_episode_not_monitored_should_return_false()
{ {
WithFirstEpisodeUnmonitored(); WithFirstEpisodeUnmonitored();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -87,28 +87,28 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
WithFirstEpisodeUnmonitored(); WithFirstEpisodeUnmonitored();
WithSecondEpisodeUnmonitored(); WithSecondEpisodeUnmonitored();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
public void only_first_episode_not_monitored_should_return_monitored() public void only_first_episode_not_monitored_should_return_monitored()
{ {
WithFirstEpisodeUnmonitored(); WithFirstEpisodeUnmonitored();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void only_second_episode_not_monitored_should_return_monitored() public void only_second_episode_not_monitored_should_return_monitored()
{ {
WithSecondEpisodeUnmonitored(); WithSecondEpisodeUnmonitored();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void should_return_true_if_it_is_a_search() public void should_return_true_if_it_is_a_search()
{ {
_fakeSeries.Monitored = false; _fakeSeries.Monitored = false;
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Should().BeTrue(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Accepted.Should().BeTrue();
} }
} }
} }

@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_return_true_when_queue_is_empty() public void should_return_true_when_queue_is_empty()
{ {
GivenEmptyQueue(); GivenEmptyQueue();
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -93,7 +93,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Build(); .Build();
GivenQueue(new List<RemoteEpisode> { remoteEpisode }); GivenQueue(new List<RemoteEpisode> { remoteEpisode });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -110,7 +110,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
GivenQueue(new List<RemoteEpisode> { remoteEpisode }, TrackedDownloadState.DownloadFailed); GivenQueue(new List<RemoteEpisode> { remoteEpisode }, TrackedDownloadState.DownloadFailed);
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -126,7 +126,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Build(); .Build();
GivenQueue(new List<RemoteEpisode> { remoteEpisode }); GivenQueue(new List<RemoteEpisode> { remoteEpisode });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -142,7 +142,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Build(); .Build();
GivenQueue(new List<RemoteEpisode> { remoteEpisode }); GivenQueue(new List<RemoteEpisode> { remoteEpisode });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -158,7 +158,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Build(); .Build();
GivenQueue(new List<RemoteEpisode> { remoteEpisode }); GivenQueue(new List<RemoteEpisode> { remoteEpisode });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -174,7 +174,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Build(); .Build();
GivenQueue(new List<RemoteEpisode> { remoteEpisode }); GivenQueue(new List<RemoteEpisode> { remoteEpisode });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -190,7 +190,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Build(); .Build();
GivenQueue(new List<RemoteEpisode> { remoteEpisode }); GivenQueue(new List<RemoteEpisode> { remoteEpisode });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -208,7 +208,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_remoteEpisode.Episodes.Add(_otherEpisode); _remoteEpisode.Episodes.Add(_otherEpisode);
GivenQueue(new List<RemoteEpisode> { remoteEpisode }); GivenQueue(new List<RemoteEpisode> { remoteEpisode });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -226,7 +226,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_remoteEpisode.Episodes.Add(_otherEpisode); _remoteEpisode.Episodes.Add(_otherEpisode);
GivenQueue(new List<RemoteEpisode> { remoteEpisode }); GivenQueue(new List<RemoteEpisode> { remoteEpisode });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -249,7 +249,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_remoteEpisode.Episodes.Add(_otherEpisode); _remoteEpisode.Episodes.Add(_otherEpisode);
GivenQueue(remoteEpisodes); GivenQueue(remoteEpisodes);
Subject.IsSatisfiedBy(_remoteEpisode, null ).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
} }
} }

@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test] [Test]
public void should_be_true_when_restrictions_are_empty() public void should_be_true_when_restrictions_are_empty()
{ {
Subject.IsSatisfiedBy(_parseResult, null).Should().BeTrue(); Subject.IsSatisfiedBy(_parseResult, null).Accepted.Should().BeTrue();
} }
[TestCase("KYR")] [TestCase("KYR")]
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_be_false_when_nzb_contains_a_restricted_term(string restrictions) public void should_be_false_when_nzb_contains_a_restricted_term(string restrictions)
{ {
Mocker.GetMock<IConfigService>().SetupGet(c => c.ReleaseRestrictions).Returns(restrictions); Mocker.GetMock<IConfigService>().SetupGet(c => c.ReleaseRestrictions).Returns(restrictions);
Subject.IsSatisfiedBy(_parseResult, null).Should().BeFalse(); Subject.IsSatisfiedBy(_parseResult, null).Accepted.Should().BeFalse();
} }
[TestCase("NotReal")] [TestCase("NotReal")]
@ -47,14 +47,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_be_true_when_nzb_does_not_contain_a_restricted_term(string restrictions) public void should_be_true_when_nzb_does_not_contain_a_restricted_term(string restrictions)
{ {
Mocker.GetMock<IConfigService>().SetupGet(c => c.ReleaseRestrictions).Returns(restrictions); Mocker.GetMock<IConfigService>().SetupGet(c => c.ReleaseRestrictions).Returns(restrictions);
Subject.IsSatisfiedBy(_parseResult, null).Should().BeTrue(); Subject.IsSatisfiedBy(_parseResult, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void should_not_try_to_find_empty_string_as_a_match() public void should_not_try_to_find_empty_string_as_a_match()
{ {
Mocker.GetMock<IConfigService>().SetupGet(c => c.ReleaseRestrictions).Returns("test\n"); Mocker.GetMock<IConfigService>().SetupGet(c => c.ReleaseRestrictions).Returns("test\n");
Subject.IsSatisfiedBy(_parseResult, null).Should().BeTrue(); Subject.IsSatisfiedBy(_parseResult, null).Accepted.Should().BeTrue();
} }
} }
} }

@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p); remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
Subject.IsSatisfiedBy(remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test, TestCaseSource("DeniedTestCases")] [Test, TestCaseSource("DeniedTestCases")]
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p); remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
Subject.IsSatisfiedBy(remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeFalse();
} }
} }
} }

@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
WithRetention(0); WithRetention(0);
WithAge(100); WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue(); Subject.IsSatisfiedBy(parseResult, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
WithRetention(1000); WithRetention(1000);
WithAge(100); WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue(); Subject.IsSatisfiedBy(parseResult, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
WithRetention(100); WithRetention(100);
WithAge(100); WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue(); Subject.IsSatisfiedBy(parseResult, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
WithRetention(10); WithRetention(10);
WithAge(100); WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeFalse(); Subject.IsSatisfiedBy(parseResult, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
WithRetention(0); WithRetention(0);
WithAge(100); WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue(); Subject.IsSatisfiedBy(parseResult, null).Accepted.Should().BeTrue();
} }
} }
} }

@ -75,7 +75,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
[Test] [Test]
public void should_be_true_when_search() public void should_be_true_when_search()
{ {
Subject.IsSatisfiedBy(new RemoteEpisode(), new SingleEpisodeSearchCriteria()).Should().BeTrue(); Subject.IsSatisfiedBy(new RemoteEpisode(), new SingleEpisodeSearchCriteria()).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
{ {
_profile.GrabDelay = 0; _profile.GrabDelay = 0;
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
{ {
_remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.Bluray720p); _remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.Bluray720p);
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_profile.GrabDelay = 1; _profile.GrabDelay = 1;
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_profile.GrabDelay = 12; _profile.GrabDelay = 12;
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -131,7 +131,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_profile.GrabDelay = 12; _profile.GrabDelay = 12;
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -149,7 +149,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_profile.GrabDelay = 12; _profile.GrabDelay = 12;
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -161,7 +161,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_profile.GrabDelay = 12; _profile.GrabDelay = 12;
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -173,7 +173,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_profile.GrabDelay = 12; _profile.GrabDelay = 12;
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -185,7 +185,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_profile.GrabDelay = 12; _profile.GrabDelay = 12;
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -198,7 +198,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_profile.GrabDelay = 12; _profile.GrabDelay = 12;
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -214,7 +214,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
.Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>())) .Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>()))
.Returns(new List<RemoteEpisode>()); .Returns(new List<RemoteEpisode>());
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -230,7 +230,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
.Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>())) .Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>()))
.Returns(new List<RemoteEpisode> { _remoteEpisode.JsonClone() }); .Returns(new List<RemoteEpisode> { _remoteEpisode.JsonClone() });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -249,7 +249,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
.Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>())) .Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>()))
.Returns(new List<RemoteEpisode> { pendingRemoteEpisode }); .Returns(new List<RemoteEpisode> { pendingRemoteEpisode });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
.Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>())) .Setup(s => s.GetPendingRemoteEpisodes(It.IsAny<Int32>()))
.Returns(new List<RemoteEpisode> { pendingRemoteEpisode1, pendingRemoteEpisode2 }); .Returns(new List<RemoteEpisode> { pendingRemoteEpisode1, pendingRemoteEpisode2 });
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
} }
} }

@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_firstFile.Quality.Quality = Quality.DVD; _firstFile.Quality.Quality = Quality.DVD;
_firstFile.DateAdded = DateTime.Today.AddDays(-30); _firstFile.DateAdded = DateTime.Today.AddDays(-30);
Subject.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse(); Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_secondFile.Quality.Quality = Quality.DVD; _secondFile.Quality.Quality = Quality.DVD;
_firstFile.DateAdded = DateTime.Today.AddDays(-30); _firstFile.DateAdded = DateTime.Today.AddDays(-30);
Subject.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); Subject.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -94,7 +94,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_secondFile.Quality.Quality = Quality.DVD; _secondFile.Quality.Quality = Quality.DVD;
_secondFile.DateAdded = DateTime.Today.AddDays(-30); _secondFile.DateAdded = DateTime.Today.AddDays(-30);
Subject.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); Subject.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -103,7 +103,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
WithFirstFileUpgradable(); WithFirstFileUpgradable();
_firstFile.DateAdded = DateTime.Today.AddDays(-30); _firstFile.DateAdded = DateTime.Today.AddDays(-30);
Subject.IsSatisfiedBy(_parseResultSingle, null).Should().BeTrue(); Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
WithFirstFileUpgradable(); WithFirstFileUpgradable();
_firstFile.DateAdded = DateTime.Today.AddDays(-30); _firstFile.DateAdded = DateTime.Today.AddDays(-30);
Subject.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria()).Should().BeTrue(); Subject.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria()).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -121,7 +121,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_firstFile.Quality.Quality = Quality.DVD; _firstFile.Quality.Quality = Quality.DVD;
_firstFile.DateAdded = DateTime.Today; _firstFile.DateAdded = DateTime.Today;
Subject.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse(); Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -132,7 +132,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
_firstFile.Quality.Quality = Quality.DVD; _firstFile.Quality.Quality = Quality.DVD;
_firstFile.DateAdded = DateTime.Today; _firstFile.DateAdded = DateTime.Today;
Subject.IsSatisfiedBy(_parseResultSingle, null).Should().BeTrue(); Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
} }
} }
} }

@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
{ {
_searchCriteria.Series = _series2; _searchCriteria.Series = _series2;
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
{ {
_searchCriteria.Series = _series1; _searchCriteria.Series = _series1;
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeTrue();
} }
} }
} }

@ -71,7 +71,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_return_true_if_episode_has_no_existing_file() public void should_return_true_if_episode_has_no_existing_file()
{ {
_parseResultSingle.Episodes.ForEach(c => c.EpisodeFileId = 0); _parseResultSingle.Episodes.ForEach(c => c.EpisodeFileId = 0);
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Should().BeTrue(); _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -79,14 +79,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
_parseResultSingle.Episodes = new List<Episode>(); _parseResultSingle.Episodes = new List<Episode>();
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Should().BeTrue(); _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void should_be_upgradable_if_only_episode_is_upgradable() public void should_be_upgradable_if_only_episode_is_upgradable()
{ {
WithFirstFileUpgradable(); WithFirstFileUpgradable();
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Should().BeTrue(); _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
@ -94,27 +94,27 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
WithFirstFileUpgradable(); WithFirstFileUpgradable();
WithSecondFileUpgradable(); WithSecondFileUpgradable();
_upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue(); _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
} }
[Test] [Test]
public void should_be_not_upgradable_if_both_episodes_are_not_upgradable() public void should_be_not_upgradable_if_both_episodes_are_not_upgradable()
{ {
_upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
public void should_be_not_upgradable_if_only_first_episodes_is_upgradable() public void should_be_not_upgradable_if_only_first_episodes_is_upgradable()
{ {
WithFirstFileUpgradable(); WithFirstFileUpgradable();
_upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
public void should_be_not_upgradable_if_only_second_episodes_is_upgradable() public void should_be_not_upgradable_if_only_second_episodes_is_upgradable()
{ {
WithSecondFileUpgradable(); WithSecondFileUpgradable();
_upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Should().BeFalse(); _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse();
} }
[Test] [Test]
@ -122,7 +122,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
_firstFile.Quality = new QualityModel(Quality.WEBDL1080p); _firstFile.Quality = new QualityModel(Quality.WEBDL1080p);
_parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p); _parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p);
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse(); _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
} }
} }
} }

@ -0,0 +1,32 @@
using System;
namespace NzbDrone.Core.DecisionEngine
{
public class Decision
{
public Boolean Accepted { get; private set; }
public String Reason { get; private set; }
public static Decision Accept()
{
return new Decision
{
Accepted = true
};
}
public static Decision Reject(String reason, params object[] args)
{
return Reject(String.Format(reason, args));
}
public static Decision Reject(String reason)
{
return new Decision
{
Accepted = false,
Reason = reason
};
}
}
}

@ -8,6 +8,7 @@ using NzbDrone.Common.Serializer;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using Prowlin;
namespace NzbDrone.Core.DecisionEngine namespace NzbDrone.Core.DecisionEngine
{ {
@ -19,7 +20,7 @@ namespace NzbDrone.Core.DecisionEngine
public class DownloadDecisionMaker : IMakeDownloadDecision public class DownloadDecisionMaker : IMakeDownloadDecision
{ {
private readonly IEnumerable<IRejectWithReason> _specifications; private readonly IEnumerable<IDecisionEngineSpecification> _specifications;
private readonly IParsingService _parsingService; private readonly IParsingService _parsingService;
private readonly Logger _logger; private readonly Logger _logger;
@ -116,19 +117,15 @@ namespace NzbDrone.Core.DecisionEngine
return new DownloadDecision(remoteEpisode, reasons.ToArray()); return new DownloadDecision(remoteEpisode, reasons.ToArray());
} }
private Rejection EvaluateSpec(IRejectWithReason spec, RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase = null) private Rejection EvaluateSpec(IDecisionEngineSpecification spec, RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase = null)
{ {
try try
{ {
if (spec.RejectionReason.IsNullOrWhiteSpace()) var result = spec.IsSatisfiedBy(remoteEpisode, searchCriteriaBase);
{
throw new InvalidOperationException("[Need Rejection Text]");
}
var generalSpecification = spec as IDecisionEngineSpecification; if (!result.Accepted)
if (generalSpecification != null && !generalSpecification.IsSatisfiedBy(remoteEpisode, searchCriteriaBase))
{ {
return new Rejection(spec.RejectionReason, generalSpecification.Type); return new Rejection(result.Reason, spec.Type);
} }
} }
catch (Exception e) catch (Exception e)

@ -1,13 +1,12 @@
using System;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine namespace NzbDrone.Core.DecisionEngine
{ {
public interface IDecisionEngineSpecification : IRejectWithReason public interface IDecisionEngineSpecification
{ {
RejectionType Type { get; } RejectionType Type { get; }
Boolean IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria); Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria);
} }
} }

@ -1,6 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
@ -22,14 +23,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public String RejectionReason
{
get { return "File size too big or small"; }
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
_logger.Debug("Beginning size check for: {0}", subject); _logger.Debug("Beginning size check for: {0}", subject);
@ -38,13 +34,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (quality == Quality.RAWHD) if (quality == Quality.RAWHD)
{ {
_logger.Debug("Raw-HD release found, skipping size check."); _logger.Debug("Raw-HD release found, skipping size check.");
return true; return Decision.Accept();
} }
if (quality == Quality.Unknown) if (quality == Quality.Unknown)
{ {
_logger.Debug("Unknown quality. skipping size check."); _logger.Debug("Unknown quality. skipping size check.");
return false; return Decision.Accept();
} }
var qualityDefinition = _qualityDefinitionService.Get(quality); var qualityDefinition = _qualityDefinitionService.Get(quality);
@ -56,8 +52,8 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
//If the parsed size is smaller than minSize we don't want it //If the parsed size is smaller than minSize we don't want it
if (subject.Release.Size < minSize) if (subject.Release.Size < minSize)
{ {
_logger.Debug("Item: {0}, Size: {1} is smaller than minimum allowed size ({2}), rejecting.", subject, subject.Release.Size, minSize); _logger.Debug("Item: {0}, Size: {1:0n} is smaller than minimum allowed size ({2:0}), rejecting.", subject, subject.Release.Size, minSize);
return false; return Decision.Reject("{0} is smaller than minimum allowed: {1}", subject.Release.Size.SizeSuffix(), minSize.SizeSuffix());
} }
if (qualityDefinition.MaxSize == 0) if (qualityDefinition.MaxSize == 0)
{ {
@ -97,11 +93,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (subject.Release.Size > maxSize) if (subject.Release.Size > maxSize)
{ {
_logger.Debug("Item: {0}, Size: {1} is greater than maximum allowed size ({2}), rejecting.", subject, subject.Release.Size, maxSize); _logger.Debug("Item: {0}, Size: {1} is greater than maximum allowed size ({2}), rejecting.", subject, subject.Release.Size, maxSize);
return false; return Decision.Reject("{0} is larger than maximum allowed: {1}", subject.Release.Size, maxSize);
} }
} }
_logger.Debug("Item: {0}, meets size constraints.", subject); _logger.Debug("Item: {0}, meets size constraints.", subject);
return true; return Decision.Accept();
} }
} }
} }

@ -18,23 +18,15 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Version upgrade for a different release group";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
var releaseGroup = subject.ParsedEpisodeInfo.ReleaseGroup; var releaseGroup = subject.ParsedEpisodeInfo.ReleaseGroup;
if (subject.Series.SeriesType != SeriesTypes.Anime) if (subject.Series.SeriesType != SeriesTypes.Anime)
{ {
return true; return Decision.Accept();
} }
foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
@ -44,24 +36,24 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (file.ReleaseGroup.IsNullOrWhiteSpace()) if (file.ReleaseGroup.IsNullOrWhiteSpace())
{ {
_logger.Debug("Unable to compare release group, existing file's release group is unknown"); _logger.Debug("Unable to compare release group, existing file's release group is unknown");
return false; return Decision.Reject("Existing release group is unknown");
} }
if (releaseGroup.IsNullOrWhiteSpace()) if (releaseGroup.IsNullOrWhiteSpace())
{ {
_logger.Debug("Unable to compare release group, release's release group is unknown"); _logger.Debug("Unable to compare release group, release's release group is unknown");
return false; return Decision.Reject("Release group is unknown");
} }
if (file.ReleaseGroup != releaseGroup) if (file.ReleaseGroup != releaseGroup)
{ {
_logger.Debug("Existing Release group is: {0} - release's release group is: {1}", file.ReleaseGroup, releaseGroup); _logger.Debug("Existing Release group is: {0} - release's release group is: {1}", file.ReleaseGroup, releaseGroup);
return false; return Decision.Reject("{0} does not match existing release group {1}", releaseGroup, file.ReleaseGroup);
} }
} }
} }
return true; return Decision.Accept();
} }
} }
} }

@ -19,31 +19,23 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Release is blacklisted";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
if (!_configService.EnableFailedDownloadHandling) if (!_configService.EnableFailedDownloadHandling)
{ {
_logger.Debug("Failed Download Handling is not enabled"); _logger.Debug("Failed Download Handling is not enabled");
return true; return Decision.Accept();
} }
if (_blacklistService.Blacklisted(subject.Series.Id, subject.Release.Title, subject.Release.PublishDate)) if (_blacklistService.Blacklisted(subject.Series.Id, subject.Release.Title, subject.Release.PublishDate))
{ {
_logger.Debug("{0} is blacklisted, rejecting.", subject.Release.Title); _logger.Debug("{0} is blacklisted, rejecting.", subject.Release.Title);
return false; return Decision.Reject("Release is blacklisted");
} }
return true; return Decision.Accept();
} }
} }
} }

@ -16,17 +16,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Cutoff has already been met";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
{ {
@ -36,11 +28,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality)) if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality))
{ {
_logger.Debug("Cutoff already met, rejecting."); _logger.Debug("Cutoff already met, rejecting.");
return false; return Decision.Reject("Existing file meets cutoff: {0}", subject.Series.Profile);
} }
} }
return true; return Decision.Accept();
} }
} }
} }

@ -13,17 +13,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Language is not wanted";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
var wantedLanguage = subject.Series.Profile.Value.Language; var wantedLanguage = subject.Series.Profile.Value.Language;
@ -32,10 +24,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (subject.ParsedEpisodeInfo.Language != wantedLanguage) if (subject.ParsedEpisodeInfo.Language != wantedLanguage)
{ {
_logger.Debug("Report Language: {0} rejected because it is not wanted, wanted {1}", subject.ParsedEpisodeInfo.Language, wantedLanguage); _logger.Debug("Report Language: {0} rejected because it is not wanted, wanted {1}", subject.ParsedEpisodeInfo.Language, wantedLanguage);
return false; return Decision.Reject("{0} is wanted, but found {1}", wantedLanguage, subject.ParsedEpisodeInfo.Language);
} }
return true; return Decision.Accept();
} }
} }
} }

@ -19,17 +19,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Already in download queue.";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
var queue = _downloadTrackingService.GetQueuedDownloads() var queue = _downloadTrackingService.GetQueuedDownloads()
.Where(v => v.State == TrackedDownloadState.Downloading) .Where(v => v.State == TrackedDownloadState.Downloading)
@ -38,10 +30,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (IsInQueue(subject, queue)) if (IsInQueue(subject, queue))
{ {
_logger.Debug("Already in queue, rejecting."); _logger.Debug("Already in queue, rejecting.");
return false; return Decision.Reject("Already in download queue");
} }
return true; return Decision.Accept();
} }
private bool IsInQueue(RemoteEpisode newEpisode, IEnumerable<RemoteEpisode> queue) private bool IsInQueue(RemoteEpisode newEpisode, IEnumerable<RemoteEpisode> queue)

@ -17,17 +17,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Contains restricted term.";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
_logger.Debug("Checking if release contains any restricted terms: {0}", subject); _logger.Debug("Checking if release contains any restricted terms: {0}", subject);
@ -36,7 +28,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (String.IsNullOrWhiteSpace(restrictionsString)) if (String.IsNullOrWhiteSpace(restrictionsString))
{ {
_logger.Debug("No restrictions configured, allowing: {0}", subject); _logger.Debug("No restrictions configured, allowing: {0}", subject);
return true; return Decision.Accept();
} }
var restrictions = restrictionsString.Split(new []{ '\n' }, StringSplitOptions.RemoveEmptyEntries); var restrictions = restrictionsString.Split(new []{ '\n' }, StringSplitOptions.RemoveEmptyEntries);
@ -46,12 +38,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (subject.Release.Title.ToLowerInvariant().Contains(restriction.ToLowerInvariant())) if (subject.Release.Title.ToLowerInvariant().Contains(restriction.ToLowerInvariant()))
{ {
_logger.Debug("{0} is restricted: {1}", subject, restriction); _logger.Debug("{0} is restricted: {1}", subject, restriction);
return false; return Decision.Reject("Contains restricted term: {0}", restriction);
} }
} }
_logger.Debug("No restrictions apply, allowing: {0}", subject); _logger.Debug("No restrictions apply, allowing: {0}", subject);
return true; return Decision.Accept();
} }
} }
} }

@ -8,7 +8,6 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
{ {
private readonly Logger _logger; private readonly Logger _logger;
public string RejectionReason { get { return "Sample"; } }
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public NotSampleSpecification(Logger logger) public NotSampleSpecification(Logger logger)
@ -16,15 +15,15 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
if (subject.Release.Title.ToLower().Contains("sample") && subject.Release.Size < 70.Megabytes()) if (subject.Release.Title.ToLower().Contains("sample") && subject.Release.Size < 70.Megabytes())
{ {
_logger.Debug("Sample release, rejecting."); _logger.Debug("Sample release, rejecting.");
return false; return Decision.Reject("Sample");
} }
return true; return Decision.Accept();
} }
} }
} }

@ -13,26 +13,18 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Quality rejected by series profile";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
_logger.Debug("Checking if report meets quality requirements. {0}", subject.ParsedEpisodeInfo.Quality); _logger.Debug("Checking if report meets quality requirements. {0}", subject.ParsedEpisodeInfo.Quality);
if (!subject.Series.Profile.Value.Items.Exists(v => v.Allowed && v.Quality == subject.ParsedEpisodeInfo.Quality.Quality)) if (!subject.Series.Profile.Value.Items.Exists(v => v.Allowed && v.Quality == subject.ParsedEpisodeInfo.Quality.Quality))
{ {
_logger.Debug("Quality {0} rejected by Series' quality profile", subject.ParsedEpisodeInfo.Quality); _logger.Debug("Quality {0} rejected by Series' quality profile", subject.ParsedEpisodeInfo.Quality);
return false; return Decision.Reject("{0} is not wanted in profile", subject.ParsedEpisodeInfo.Quality.Quality);
} }
return true; return Decision.Accept();
} }
} }
} }

@ -16,18 +16,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Report past retention limit.";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
var age = subject.Release.Age; var age = subject.Release.Age;
var retention = _configService.Retention; var retention = _configService.Retention;
@ -36,10 +27,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (retention > 0 && age > retention) if (retention > 0 && age > retention)
{ {
_logger.Debug("Report age: {0} rejected by user's retention limit", age); _logger.Debug("Report age: {0} rejected by user's retention limit", age);
return false; return Decision.Reject("Older than configured retention");
} }
return true; return Decision.Accept();
} }
} }
} }

@ -22,22 +22,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Release has been retried too many times";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
if (!_configService.EnableFailedDownloadHandling) if (!_configService.EnableFailedDownloadHandling)
{ {
_logger.Debug("Failed Download Handling is not enabled"); _logger.Debug("Failed Download Handling is not enabled");
return true; return Decision.Accept();
} }
var history = _historyService.FindBySourceTitle(subject.Release.Title); var history = _historyService.FindBySourceTitle(subject.Release.Title);
@ -47,10 +39,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_configService.BlacklistRetryLimit) _configService.BlacklistRetryLimit)
{ {
_logger.Debug("Release has been attempted more times than allowed, rejecting"); _logger.Debug("Release has been attempted more times than allowed, rejecting");
return false; return Decision.Reject("Retried too many times");
} }
return true; return Decision.Accept();
} }
private bool HasSamePublishedDate(History.History item, DateTime publishedDate) private bool HasSamePublishedDate(History.History item, DateTime publishedDate)

@ -21,17 +21,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Waiting for better quality release";
}
}
public RejectionType Type { get { return RejectionType.Temporary; } } public RejectionType Type { get { return RejectionType.Temporary; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
//How do we want to handle drone being off and the automatic search being triggered? //How do we want to handle drone being off and the automatic search being triggered?
//TODO: Add a flag to the search to state it is a "scheduled" search //TODO: Add a flag to the search to state it is a "scheduled" search
@ -39,7 +31,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (searchCriteria != null) if (searchCriteria != null)
{ {
_logger.Debug("Ignore delay for searches"); _logger.Debug("Ignore delay for searches");
return true; return Decision.Accept();
} }
var profile = subject.Series.Profile.Value; var profile = subject.Series.Profile.Value;
@ -47,7 +39,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (profile.GrabDelay == 0) if (profile.GrabDelay == 0)
{ {
_logger.Debug("Profile does not delay before download"); _logger.Debug("Profile does not delay before download");
return true; return Decision.Accept();
} }
var comparer = new QualityModelComparer(profile); var comparer = new QualityModelComparer(profile);
@ -63,7 +55,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (revisionUpgrade) if (revisionUpgrade)
{ {
_logger.Debug("New quality is a better revision for existing quality, skipping delay"); _logger.Debug("New quality is a better revision for existing quality, skipping delay");
return true; return Decision.Accept();
} }
} }
} }
@ -75,7 +67,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (bestCompare >= 0) if (bestCompare >= 0)
{ {
_logger.Debug("Quality is highest in profile, will not delay"); _logger.Debug("Quality is highest in profile, will not delay");
return true; return Decision.Accept();
} }
if (profile.GrabDelayMode == GrabDelayMode.Cutoff) if (profile.GrabDelayMode == GrabDelayMode.Cutoff)
@ -86,7 +78,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (cutoffCompare >= 0) if (cutoffCompare >= 0)
{ {
_logger.Debug("Quality meets or exceeds the cutoff, will not delay"); _logger.Debug("Quality meets or exceeds the cutoff, will not delay");
return true; return Decision.Accept();
} }
} }
@ -101,17 +93,17 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (oldest != null && oldest.Release.AgeHours > profile.GrabDelay) if (oldest != null && oldest.Release.AgeHours > profile.GrabDelay)
{ {
return true; return Decision.Accept();
} }
} }
if (subject.Release.AgeHours < profile.GrabDelay) if (subject.Release.AgeHours < profile.GrabDelay)
{ {
_logger.Debug("Age ({0}) is less than delay {1}, delaying", subject.Release.AgeHours, profile.GrabDelay); _logger.Debug("Age ({0}) is less than delay {1}, delaying", subject.Release.AgeHours, profile.GrabDelay);
return false; return Decision.Reject("Waiting for better quality release");
} }
return true; return Decision.Accept();
} }
} }
} }

@ -26,22 +26,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Existing file in history is of equal or higher quality";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
if (searchCriteria != null) if (searchCriteria != null)
{ {
_logger.Debug("Skipping history check during search"); _logger.Debug("Skipping history check during search");
return true; return Decision.Accept();
} }
var downloadClients = _downloadClientProvider.GetDownloadClients(); var downloadClients = _downloadClientProvider.GetDownloadClients();
@ -57,10 +49,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (mostRecent != null && mostRecent.EventType == HistoryEventType.Grabbed) if (mostRecent != null && mostRecent.EventType == HistoryEventType.Grabbed)
{ {
_logger.Debug("Latest history item is downloading, rejecting."); _logger.Debug("Latest history item is downloading, rejecting.");
return false; return Decision.Reject("Download has not been imported yet");
} }
} }
return true; return Decision.Accept();
} }
foreach (var episode in subject.Episodes) foreach (var episode in subject.Episodes)
@ -69,12 +61,15 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (bestQualityInHistory != null) if (bestQualityInHistory != null)
{ {
_logger.Debug("Comparing history quality with report. History is {0}", bestQualityInHistory); _logger.Debug("Comparing history quality with report. History is {0}", bestQualityInHistory);
if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, bestQualityInHistory, subject.ParsedEpisodeInfo.Quality)) if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, bestQualityInHistory, subject.ParsedEpisodeInfo.Quality))
return false; {
return Decision.Reject("Existing file in history is of equal or higher quality: {0}", bestQualityInHistory);
}
} }
} }
return true; return Decision.Accept();
} }
} }
} }

@ -14,38 +14,30 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Series or Episode is not monitored";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
if (searchCriteria != null) if (searchCriteria != null)
{ {
_logger.Debug("Skipping monitored check during search"); _logger.Debug("Skipping monitored check during search");
return true; return Decision.Accept();
} }
if (!subject.Series.Monitored) if (!subject.Series.Monitored)
{ {
_logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Series); _logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Series);
return false; return Decision.Reject("Series is not monitored");
} }
//return monitored if any of the episodes are monitored //return monitored if any of the episodes are monitored
if (subject.Episodes.Any(episode => episode.Monitored)) if (subject.Episodes.Any(episode => episode.Monitored))
{ {
return true; return Decision.Accept();
} }
_logger.Debug("No episodes are monitored. skipping."); _logger.Debug("No episodes are monitored. skipping.");
return false; return Decision.Reject("Episode is not monitored");
} }
} }
} }

@ -20,21 +20,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Proper for old episode";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
if (searchCriteria != null) if (searchCriteria != null)
{ {
return true; return Decision.Accept();
} }
foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
@ -44,18 +36,18 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (file.DateAdded < DateTime.Today.AddDays(-7)) if (file.DateAdded < DateTime.Today.AddDays(-7))
{ {
_logger.Debug("Proper for old file, rejecting: {0}", subject); _logger.Debug("Proper for old file, rejecting: {0}", subject);
return false; return Decision.Reject("Proper for old file");
} }
if (!_configService.AutoDownloadPropers) if (!_configService.AutoDownloadPropers)
{ {
_logger.Debug("Auto downloading of propers is disabled"); _logger.Debug("Auto downloading of propers is disabled");
return false; return Decision.Reject("Proper downloading is disabled");
} }
} }
} }
return true; return Decision.Accept();
} }
} }
} }

@ -16,36 +16,28 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
_episodeService = episodeService; _episodeService = episodeService;
} }
public string RejectionReason
{
get
{
return "Episode doesn't match";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
{ {
if (searchCriteria == null) if (searchCriteria == null)
{ {
return true; return Decision.Accept();
} }
var dailySearchSpec = searchCriteria as DailyEpisodeSearchCriteria; var dailySearchSpec = searchCriteria as DailyEpisodeSearchCriteria;
if (dailySearchSpec == null) return true; if (dailySearchSpec == null) return Decision.Accept();
var episode = _episodeService.GetEpisode(dailySearchSpec.Series.Id, dailySearchSpec.AirDate.ToString(Episode.AIR_DATE_FORMAT)); var episode = _episodeService.GetEpisode(dailySearchSpec.Series.Id, dailySearchSpec.AirDate.ToString(Episode.AIR_DATE_FORMAT));
if (!remoteEpisode.ParsedEpisodeInfo.IsDaily || remoteEpisode.ParsedEpisodeInfo.AirDate != episode.AirDate) if (!remoteEpisode.ParsedEpisodeInfo.IsDaily || remoteEpisode.ParsedEpisodeInfo.AirDate != episode.AirDate)
{ {
_logger.Debug("Episode AirDate does not match searched episode number, skipping."); _logger.Debug("Episode AirDate does not match searched episode number, skipping.");
return false; return Decision.Reject("Episode does not match");
} }
return true; return Decision.Accept();
} }
} }
} }

@ -15,31 +15,25 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Episode wasn't requested";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
{ {
if (searchCriteria == null) if (searchCriteria == null)
{ {
return true; return Decision.Accept();
} }
var criteriaEpisodes = searchCriteria.Episodes.Select(v => v.Id).ToList(); var criteriaEpisodes = searchCriteria.Episodes.Select(v => v.Id).ToList();
var remoteEpisodes = remoteEpisode.Episodes.Select(v => v.Id).ToList(); var remoteEpisodes = remoteEpisode.Episodes.Select(v => v.Id).ToList();
if (!criteriaEpisodes.Intersect(remoteEpisodes).Any()) if (!criteriaEpisodes.Intersect(remoteEpisodes).Any())
{ {
_logger.Debug("Release rejected since the episode wasn't requested: {0}", remoteEpisode.ParsedEpisodeInfo); _logger.Debug("Release rejected since the episode wasn't requested: {0}", remoteEpisode.ParsedEpisodeInfo);
return false; return Decision.Reject("Episode wasn't requested");
} }
return true; return Decision.Accept();
} }
} }
} }

@ -13,33 +13,25 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Episode doesn't match";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
{ {
if (searchCriteria == null) if (searchCriteria == null)
{ {
return true; return Decision.Accept();
} }
var singleEpisodeSpec = searchCriteria as SeasonSearchCriteria; var singleEpisodeSpec = searchCriteria as SeasonSearchCriteria;
if (singleEpisodeSpec == null) return true; if (singleEpisodeSpec == null) return Decision.Accept();
if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber)
{ {
_logger.Debug("Season number does not match searched season number, skipping."); _logger.Debug("Season number does not match searched season number, skipping.");
return false; return Decision.Reject("Wrong season");
} }
return true; return Decision.Accept();
} }
} }
} }

@ -13,21 +13,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Wrong series";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
{ {
if (searchCriteria == null) if (searchCriteria == null)
{ {
return true; return Decision.Accept();
} }
_logger.Debug("Checking if series matches searched series"); _logger.Debug("Checking if series matches searched series");
@ -35,10 +27,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
if (remoteEpisode.Series.Id != searchCriteria.Series.Id) if (remoteEpisode.Series.Id != searchCriteria.Series.Id)
{ {
_logger.Debug("Series {0} does not match {1}", remoteEpisode.Series, searchCriteria.Series); _logger.Debug("Series {0} does not match {1}", remoteEpisode.Series, searchCriteria.Series);
return false; return Decision.Reject("Wrong series");
} }
return true; return Decision.Accept();
} }
} }
} }

@ -14,39 +14,31 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Episode doesn't match";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
{ {
if (searchCriteria == null) if (searchCriteria == null)
{ {
return true; return Decision.Accept();
} }
var singleEpisodeSpec = searchCriteria as SingleEpisodeSearchCriteria; var singleEpisodeSpec = searchCriteria as SingleEpisodeSearchCriteria;
if (singleEpisodeSpec == null) return true; if (singleEpisodeSpec == null) return Decision.Accept();
if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber)
{ {
_logger.Debug("Season number does not match searched season number, skipping."); _logger.Debug("Season number does not match searched season number, skipping.");
return false; return Decision.Reject("Wrong season");
} }
if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber)) if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber))
{ {
_logger.Debug("Episode number does not match searched episode number, skipping."); _logger.Debug("Episode number does not match searched episode number, skipping.");
return false; return Decision.Reject("Wrong episode");
} }
return true; return Decision.Accept();
} }
} }
} }

@ -16,17 +16,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger = logger; _logger = logger;
} }
public string RejectionReason
{
get
{
return "Existing file on disk is of equal or higher quality";
}
}
public RejectionType Type { get { return RejectionType.Permanent; } } public RejectionType Type { get { return RejectionType.Permanent; } }
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
{ {
@ -34,11 +26,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality)) if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality))
{ {
return false; return Decision.Reject("Existing file on disk is of equal or higher quality: {0}", file.Quality);
} }
} }
return true; return Decision.Accept();
} }
} }
} }

@ -247,6 +247,7 @@
<Compile Include="Datastore\PagingSpec.cs" /> <Compile Include="Datastore\PagingSpec.cs" />
<Compile Include="Datastore\ResultSet.cs" /> <Compile Include="Datastore\ResultSet.cs" />
<Compile Include="Datastore\TableMapping.cs" /> <Compile Include="Datastore\TableMapping.cs" />
<Compile Include="DecisionEngine\Decision.cs" />
<Compile Include="DecisionEngine\DownloadDecision.cs" /> <Compile Include="DecisionEngine\DownloadDecision.cs" />
<Compile Include="DecisionEngine\DownloadDecisionMaker.cs" /> <Compile Include="DecisionEngine\DownloadDecisionMaker.cs" />
<Compile Include="DecisionEngine\DownloadDecisionPriorizationService.cs" /> <Compile Include="DecisionEngine\DownloadDecisionPriorizationService.cs" />

Loading…
Cancel
Save