mirror of https://github.com/lidarr/Lidarr
Repack/propers for older episodes are no more
#ND-53 Fixed: Do not download Propers/Repacks for episodes older than 7 days
This commit is contained in:
parent
02e21c7d7e
commit
b7229dea06
|
@ -1,5 +1,6 @@
|
|||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
|
@ -31,8 +32,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests
|
|||
Mocker.Resolve<QualityUpgradeSpecification>();
|
||||
_upgradeDisk = Mocker.Resolve<UpgradeDiskSpecification>();
|
||||
|
||||
firstFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true };
|
||||
secondFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true };
|
||||
firstFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true, DateAdded = DateTime.Now };
|
||||
secondFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true, DateAdded = DateTime.Now };
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = null } };
|
||||
var doubleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = secondFile }, new Episode { EpisodeFile = null } };
|
||||
|
@ -121,5 +122,26 @@ namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests
|
|||
parseResultSingle.Quality = new QualityModel(QualityTypes.WEBDL1080p, false);
|
||||
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_episodeFile_was_added_more_than_7_days_ago()
|
||||
{
|
||||
firstFile.DateAdded = DateTime.Today.AddDays(-30);
|
||||
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_first_episodeFile_was_added_more_than_7_days_ago()
|
||||
{
|
||||
firstFile.DateAdded = DateTime.Today.AddDays(-30);
|
||||
_upgradeDisk.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_second_episodeFile_was_added_more_than_7_days_ago()
|
||||
{
|
||||
secondFile.DateAdded = DateTime.Today.AddDays(-30);
|
||||
_upgradeDisk.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
|
@ -6,13 +7,11 @@ namespace NzbDrone.Core.Providers.DecisionEngine
|
|||
{
|
||||
public class UpgradeDiskSpecification
|
||||
{
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly QualityUpgradeSpecification _qualityUpgradeSpecification;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public UpgradeDiskSpecification(EpisodeProvider episodeProvider, QualityUpgradeSpecification qualityUpgradeSpecification)
|
||||
public UpgradeDiskSpecification(QualityUpgradeSpecification qualityUpgradeSpecification)
|
||||
{
|
||||
_episodeProvider = episodeProvider;
|
||||
_qualityUpgradeSpecification = qualityUpgradeSpecification;
|
||||
}
|
||||
|
||||
|
@ -27,6 +26,12 @@ namespace NzbDrone.Core.Providers.DecisionEngine
|
|||
logger.Trace("Comparing file quality with report. Existing file is {0} proper:{1}", file.Quality, file.Proper);
|
||||
if (!_qualityUpgradeSpecification.IsSatisfiedBy(new QualityModel { Quality = file.Quality, Proper = file.Proper }, subject.Quality, subject.Series.QualityProfile.Cutoff))
|
||||
return false;
|
||||
|
||||
if(subject.Quality.Proper && file.DateAdded < DateTime.Today.AddDays(-7))
|
||||
{
|
||||
logger.Trace("Proper for old file, skipping: {0}", subject);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue