Added option to not auto download propers

This commit is contained in:
Mark McDowall 2013-08-11 23:00:40 -07:00
parent 5b25f9c799
commit a4d6851be1
8 changed files with 56 additions and 5 deletions

View File

@ -1,5 +1,6 @@
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine;
@ -24,11 +25,30 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
new object[] { Quality.WEBDL1080p, false, Quality.WEBDL1080p, false, Quality.WEBDL1080p, false } new object[] { Quality.WEBDL1080p, false, Quality.WEBDL1080p, false, Quality.WEBDL1080p, false }
}; };
private void GivenAutoDownloadPropers(bool autoDownloadPropers)
{
Mocker.GetMock<IConfigService>()
.SetupGet(s => s.AutoDownloadPropers)
.Returns(autoDownloadPropers);
}
[Test, TestCaseSource("IsUpgradeTestCases")] [Test, TestCaseSource("IsUpgradeTestCases")]
public void IsUpgradeTest(Quality current, bool currentProper, Quality newQuality, bool newProper, Quality cutoff, bool expected) public void IsUpgradeTest(Quality current, bool currentProper, Quality newQuality, bool newProper, Quality cutoff, bool expected)
{ {
GivenAutoDownloadPropers(true);
Subject.IsUpgradable(new QualityProfile() { Cutoff = cutoff }, new QualityModel(current, currentProper), new QualityModel(newQuality, newProper)) Subject.IsUpgradable(new QualityProfile() { Cutoff = cutoff }, new QualityModel(current, currentProper), new QualityModel(newQuality, newProper))
.Should().Be(expected); .Should().Be(expected);
} }
[Test]
public void should_return_false_if_proper_and_autoDownloadPropers_is_false()
{
GivenAutoDownloadPropers(false);
Subject.IsUpgradable(new QualityProfile { Cutoff = Quality.Bluray1080p },
new QualityModel(Quality.DVD, true),
new QualityModel(Quality.DVD, false)).Should().BeFalse();
}
} }
} }

View File

@ -2,7 +2,7 @@
using FizzWare.NBuilder; using FizzWare.NBuilder;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
using NzbDrone.Core.History; using NzbDrone.Core.History;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;

View File

@ -251,6 +251,13 @@ namespace NzbDrone.Core.Configuration
set { SetValue("RssSyncInterval", value); } set { SetValue("RssSyncInterval", value); }
} }
public Boolean AutoDownloadPropers
{
get { return GetValueBoolean("AutoDownloadPropers", true); }
set { SetValue("AutoDownloadPropers", value); }
}
private string GetValue(string key) private string GetValue(string key)
{ {
return GetValue(key, String.Empty); return GetValue(key, String.Empty);

View File

@ -37,6 +37,7 @@ namespace NzbDrone.Core.Configuration
PriorityType NzbgetOlderTvPriority { get; set; } PriorityType NzbgetOlderTvPriority { get; set; }
string ReleaseRestrictions { get; set; } string ReleaseRestrictions { get; set; }
Int32 RssSyncInterval { get; set; } Int32 RssSyncInterval { get; set; }
Boolean AutoDownloadPropers { get; set; }
void SaveValues(Dictionary<string, object> configValues); void SaveValues(Dictionary<string, object> configValues);
} }
} }

View File

@ -1,4 +1,5 @@
using NLog; using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
@ -11,10 +12,12 @@ namespace NzbDrone.Core.DecisionEngine
public class QualityUpgradableSpecification : IQualityUpgradableSpecification public class QualityUpgradableSpecification : IQualityUpgradableSpecification
{ {
private readonly IConfigService _configService;
private readonly Logger _logger; private readonly Logger _logger;
public QualityUpgradableSpecification(Logger logger) public QualityUpgradableSpecification(IConfigService configService, Logger logger)
{ {
_configService = configService;
_logger = logger; _logger = logger;
} }
@ -28,7 +31,7 @@ namespace NzbDrone.Core.DecisionEngine
return false; return false;
} }
if (currentQuality.Quality == newQuality.Quality && newQuality.Proper) if (currentQuality.Quality == newQuality.Quality && newQuality.Proper && _configService.AutoDownloadPropers)
{ {
_logger.Trace("Upgrading existing item to proper."); _logger.Trace("Upgrading existing item to proper.");
return true; return true;

View File

@ -3,7 +3,7 @@ using NzbDrone.Core.History;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
{ {
public class UpgradeHistorySpecification : IDecisionEngineSpecification public class UpgradeHistorySpecification : IDecisionEngineSpecification
{ {

View File

@ -186,7 +186,7 @@
<Compile Include="DecisionEngine\QualityUpgradableSpecification.cs" /> <Compile Include="DecisionEngine\QualityUpgradableSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\SingleEpisodeSearchMatchSpecification.cs" /> <Compile Include="DecisionEngine\Specifications\Search\SingleEpisodeSearchMatchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\UpgradeDiskSpecification.cs" /> <Compile Include="DecisionEngine\Specifications\UpgradeDiskSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\UpgradeHistorySpecification.cs" /> <Compile Include="DecisionEngine\Specifications\RssSync\UpgradeHistorySpecification.cs" />
<Compile Include="Download\Clients\Sabnzbd\ConnectionInfoModel.cs" /> <Compile Include="Download\Clients\Sabnzbd\ConnectionInfoModel.cs" />
<Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdPriorityTypeConverter.cs" /> <Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdPriorityTypeConverter.cs" />
<Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdQueueTimeConverter.cs" /> <Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdQueueTimeConverter.cs" />

View File

@ -20,4 +20,24 @@
</span> </span>
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label">Download Propers</label>
<div class="controls">
<label class="checkbox toggle well">
<input type="checkbox" name="autoDownloadPropers"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-question-sign" title="Should NzbDrone automatically upgrade to propers when available?"/>
</span>
</div>
</div>
</fieldset> </fieldset>