2012-02-07 06:08:07 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using Ninject;
|
|
|
|
|
using NzbDrone.Core.Model;
|
2012-04-20 08:42:13 +02:00
|
|
|
|
using NzbDrone.Core.Repository.Search;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-20 08:42:13 +02:00
|
|
|
|
public virtual ReportRejectionType IsSatisfiedBy(EpisodeParseResult subject)
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2012-04-20 08:42:13 +02:00
|
|
|
|
if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.QualityNotWanted;
|
|
|
|
|
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.ExistingQualityIsEqualOrBetter;
|
|
|
|
|
if (!_retentionSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.Retention;
|
|
|
|
|
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.Size;
|
|
|
|
|
if (_alreadyInQueueSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.AlreadyInQueue;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
|
|
|
|
logger.Debug("Episode {0} is needed", subject);
|
2012-04-20 08:42:13 +02:00
|
|
|
|
return ReportRejectionType.None;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|