2012-02-07 06:08:07 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using Ninject;
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers.DecisionEngine
|
|
|
|
|
{
|
|
|
|
|
public class AllowedDownloadSpecification
|
|
|
|
|
{
|
|
|
|
|
private readonly QualityAllowedByProfileSpecification _qualityAllowedByProfileSpecification;
|
|
|
|
|
private readonly UpgradeDiskSpecification _upgradeDiskSpecification;
|
|
|
|
|
private readonly AcceptableSizeSpecification _acceptableSizeSpecification;
|
|
|
|
|
private readonly AlreadyInQueueSpecification _alreadyInQueueSpecification;
|
2012-02-17 10:32:33 +01:00
|
|
|
|
private readonly RetentionSpecification _retentionSpecification;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification,
|
|
|
|
|
UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification,
|
2012-02-17 10:32:33 +01:00
|
|
|
|
AlreadyInQueueSpecification alreadyInQueueSpecification, RetentionSpecification retentionSpecification)
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
|
|
|
|
_qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification;
|
|
|
|
|
_upgradeDiskSpecification = upgradeDiskSpecification;
|
|
|
|
|
_acceptableSizeSpecification = acceptableSizeSpecification;
|
|
|
|
|
_alreadyInQueueSpecification = alreadyInQueueSpecification;
|
2012-02-17 10:32:33 +01:00
|
|
|
|
_retentionSpecification = retentionSpecification;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AllowedDownloadSpecification()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
|
|
|
|
{
|
|
|
|
|
if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return false;
|
|
|
|
|
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return false;
|
2012-02-17 10:32:33 +01:00
|
|
|
|
if (!_retentionSpecification.IsSatisfiedBy(subject)) return false;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return false;
|
|
|
|
|
if (_alreadyInQueueSpecification.IsSatisfiedBy(subject)) return false;
|
|
|
|
|
|
|
|
|
|
logger.Debug("Episode {0} is needed", subject);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|