Retention check added to DecisionEngine.
Retention is configurable from Settings/Indexers.
This commit is contained in:
parent
8c0efac00b
commit
462eb53897
|
@ -40,6 +40,8 @@ namespace NzbDrone.Core.Model
|
||||||
|
|
||||||
public long Size { get; set; }
|
public long Size { get; set; }
|
||||||
|
|
||||||
|
public int Age { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (AirDate != null && EpisodeNumbers == null)
|
if (AirDate != null && EpisodeNumbers == null)
|
||||||
|
|
|
@ -261,6 +261,7 @@
|
||||||
<Compile Include="Model\Xbmc\IconType.cs" />
|
<Compile Include="Model\Xbmc\IconType.cs" />
|
||||||
<Compile Include="Providers\BackupProvider.cs" />
|
<Compile Include="Providers\BackupProvider.cs" />
|
||||||
<Compile Include="Providers\DecisionEngine\AlreadyInQueueSpecification.cs" />
|
<Compile Include="Providers\DecisionEngine\AlreadyInQueueSpecification.cs" />
|
||||||
|
<Compile Include="Providers\DecisionEngine\RetentionSpecification.cs" />
|
||||||
<Compile Include="Providers\DownloadClients\BlackholeProvider.cs" />
|
<Compile Include="Providers\DownloadClients\BlackholeProvider.cs" />
|
||||||
<Compile Include="Providers\Converting\AtomicParsleyProvider.cs" />
|
<Compile Include="Providers\Converting\AtomicParsleyProvider.cs" />
|
||||||
<Compile Include="Providers\Converting\HandbrakeProvider.cs" />
|
<Compile Include="Providers\Converting\HandbrakeProvider.cs" />
|
||||||
|
|
|
@ -413,6 +413,12 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
set { SetValue("AutoIgnorePreviouslyDownloadedEpisodes", value); }
|
set { SetValue("AutoIgnorePreviouslyDownloadedEpisodes", value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual int Retention
|
||||||
|
{
|
||||||
|
get { return GetValueInt("Retention", 0); }
|
||||||
|
set { SetValue("Retention", value); }
|
||||||
|
}
|
||||||
|
|
||||||
public Guid UGuid
|
public Guid UGuid
|
||||||
{
|
{
|
||||||
get { return Guid.Parse(GetValue("UGuid", Guid.NewGuid().ToString(), persist: true)); }
|
get { return Guid.Parse(GetValue("UGuid", Guid.NewGuid().ToString(), persist: true)); }
|
||||||
|
|
|
@ -11,17 +11,19 @@ namespace NzbDrone.Core.Providers.DecisionEngine
|
||||||
private readonly UpgradeDiskSpecification _upgradeDiskSpecification;
|
private readonly UpgradeDiskSpecification _upgradeDiskSpecification;
|
||||||
private readonly AcceptableSizeSpecification _acceptableSizeSpecification;
|
private readonly AcceptableSizeSpecification _acceptableSizeSpecification;
|
||||||
private readonly AlreadyInQueueSpecification _alreadyInQueueSpecification;
|
private readonly AlreadyInQueueSpecification _alreadyInQueueSpecification;
|
||||||
|
private readonly RetentionSpecification _retentionSpecification;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification,
|
public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification,
|
||||||
UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification,
|
UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification,
|
||||||
AlreadyInQueueSpecification alreadyInQueueSpecification)
|
AlreadyInQueueSpecification alreadyInQueueSpecification, RetentionSpecification retentionSpecification)
|
||||||
{
|
{
|
||||||
_qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification;
|
_qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification;
|
||||||
_upgradeDiskSpecification = upgradeDiskSpecification;
|
_upgradeDiskSpecification = upgradeDiskSpecification;
|
||||||
_acceptableSizeSpecification = acceptableSizeSpecification;
|
_acceptableSizeSpecification = acceptableSizeSpecification;
|
||||||
_alreadyInQueueSpecification = alreadyInQueueSpecification;
|
_alreadyInQueueSpecification = alreadyInQueueSpecification;
|
||||||
|
_retentionSpecification = retentionSpecification;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AllowedDownloadSpecification()
|
public AllowedDownloadSpecification()
|
||||||
|
@ -32,6 +34,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine
|
||||||
{
|
{
|
||||||
if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return false;
|
if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return false;
|
||||||
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return false;
|
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return false;
|
||||||
|
if (!_retentionSpecification.IsSatisfiedBy(subject)) return false;
|
||||||
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return false;
|
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return false;
|
||||||
if (_alreadyInQueueSpecification.IsSatisfiedBy(subject)) return false;
|
if (_alreadyInQueueSpecification.IsSatisfiedBy(subject)) return false;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
using System.Linq;
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Core.Model;
|
||||||
|
using NzbDrone.Core.Providers.Core;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Providers.DecisionEngine
|
||||||
|
{
|
||||||
|
public class RetentionSpecification
|
||||||
|
{
|
||||||
|
private readonly ConfigProvider _configProvider;
|
||||||
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
public RetentionSpecification(ConfigProvider configProvider)
|
||||||
|
{
|
||||||
|
_configProvider = configProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RetentionSpecification()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||||
|
{
|
||||||
|
logger.Trace("Checking if report meets retention requirements. {0}", subject.Age);
|
||||||
|
if (_configProvider.Retention > 0 && subject.Age > _configProvider.Retention)
|
||||||
|
{
|
||||||
|
logger.Trace("Quality {0} rejected by user's retention limit", subject.Age);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -67,6 +67,8 @@ namespace NzbDrone.Web.Controllers
|
||||||
{
|
{
|
||||||
return View(new IndexerSettingsModel
|
return View(new IndexerSettingsModel
|
||||||
{
|
{
|
||||||
|
Retention = _configProvider.Retention,
|
||||||
|
|
||||||
NzbMatrixUsername = _configProvider.NzbMatrixUsername,
|
NzbMatrixUsername = _configProvider.NzbMatrixUsername,
|
||||||
NzbMatrixApiKey = _configProvider.NzbMatrixApiKey,
|
NzbMatrixApiKey = _configProvider.NzbMatrixApiKey,
|
||||||
|
|
||||||
|
@ -338,6 +340,8 @@ namespace NzbDrone.Web.Controllers
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
|
_configProvider.Retention = data.Retention;
|
||||||
|
|
||||||
var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrg));
|
var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrg));
|
||||||
nzbsOrgSettings.Enable = data.NzbsOrgEnabled;
|
nzbsOrgSettings.Enable = data.NzbsOrgEnabled;
|
||||||
_indexerProvider.SaveSettings(nzbsOrgSettings);
|
_indexerProvider.SaveSettings(nzbsOrgSettings);
|
||||||
|
|
|
@ -76,6 +76,12 @@ namespace NzbDrone.Web.Models
|
||||||
[Description("Enable downloading episodes from Newznab Providers")]
|
[Description("Enable downloading episodes from Newznab Providers")]
|
||||||
public bool NewznabEnabled { get; set; }
|
public bool NewznabEnabled { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Please enter a valid number of days")]
|
||||||
|
[DataType(DataType.Text)]
|
||||||
|
[DisplayName("Retention")]
|
||||||
|
[Description("Usenet provider retention in days (0 = unlimited)")]
|
||||||
|
public int Retention { get; set; }
|
||||||
|
|
||||||
public List<NewznabDefinition> NewznabDefinitions { get; set; }
|
public List<NewznabDefinition> NewznabDefinitions { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,12 @@
|
||||||
{
|
{
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.retentionContainer
|
||||||
|
{
|
||||||
|
padding-top: 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
}
|
}
|
||||||
<div class="infoBox">
|
<div class="infoBox">
|
||||||
|
@ -16,7 +22,6 @@
|
||||||
<div id="stylized">
|
<div id="stylized">
|
||||||
@using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "IndexersForm", name = "IndexersForm", @class = "settingsForm" }))
|
@using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "IndexersForm", name = "IndexersForm", @class = "settingsForm" }))
|
||||||
{
|
{
|
||||||
@Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.")
|
|
||||||
<div class="jquery-accordion">
|
<div class="jquery-accordion">
|
||||||
<h3>
|
<h3>
|
||||||
<a href="#">NZBs.org</a></h3>
|
<a href="#">NZBs.org</a></h3>
|
||||||
|
@ -106,7 +111,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
|
||||||
|
<div class="retentionContainer">
|
||||||
|
@Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.")
|
||||||
|
|
||||||
|
<label class="labelClass">@Html.LabelFor(m => m.Retention)
|
||||||
|
<span class="small">@Html.DescriptionFor(m => m.Retention)</span>
|
||||||
|
</label>
|
||||||
|
@Html.TextBoxFor(m => m.Retention, new { @class = "inputClass" })
|
||||||
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="save_button" disabled="disabled">
|
<button type="submit" class="save_button" disabled="disabled">
|
||||||
Save</button>
|
Save</button>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue