2012-02-07 08:08:07 +03:00
|
|
|
using System.Linq;
|
|
|
|
using NLog;
|
|
|
|
using Ninject;
|
|
|
|
using NzbDrone.Core.Model;
|
2012-04-20 09:42:13 +03:00
|
|
|
using NzbDrone.Core.Repository.Search;
|
2012-02-07 08:08:07 +03: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 12:32:33 +03:00
|
|
|
private readonly RetentionSpecification _retentionSpecification;
|
2012-08-07 08:24:15 +03:00
|
|
|
private readonly AllowedReleaseGroupSpecification _allowedReleaseGroupSpecification;
|
2012-09-20 18:37:40 +03:00
|
|
|
private readonly CustomStartDateSpecification _customStartDateSpecification;
|
2012-02-07 08:08:07 +03:00
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification,
|
|
|
|
UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification,
|
2012-08-07 08:24:15 +03:00
|
|
|
AlreadyInQueueSpecification alreadyInQueueSpecification, RetentionSpecification retentionSpecification,
|
2012-09-20 18:37:40 +03:00
|
|
|
AllowedReleaseGroupSpecification allowedReleaseGroupSpecification, CustomStartDateSpecification customStartDateSpecification)
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
|
|
|
_qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification;
|
|
|
|
_upgradeDiskSpecification = upgradeDiskSpecification;
|
|
|
|
_acceptableSizeSpecification = acceptableSizeSpecification;
|
|
|
|
_alreadyInQueueSpecification = alreadyInQueueSpecification;
|
2012-02-17 12:32:33 +03:00
|
|
|
_retentionSpecification = retentionSpecification;
|
2012-08-07 08:24:15 +03:00
|
|
|
_allowedReleaseGroupSpecification = allowedReleaseGroupSpecification;
|
2012-09-20 18:37:40 +03:00
|
|
|
_customStartDateSpecification = customStartDateSpecification;
|
2012-02-07 08:08:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public AllowedDownloadSpecification()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-04-20 09:42:13 +03:00
|
|
|
public virtual ReportRejectionType IsSatisfiedBy(EpisodeParseResult subject)
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
2012-04-20 09:42:13 +03:00
|
|
|
if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.QualityNotWanted;
|
2012-09-20 18:37:40 +03:00
|
|
|
if (!_customStartDateSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.AiredAfterCustomStartDate;
|
2012-04-20 09:42:13 +03:00
|
|
|
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.ExistingQualityIsEqualOrBetter;
|
|
|
|
if (!_retentionSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.Retention;
|
|
|
|
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.Size;
|
2012-08-07 08:24:15 +03:00
|
|
|
if (!_allowedReleaseGroupSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.ReleaseGroupNotWanted;
|
2012-04-20 09:42:13 +03:00
|
|
|
if (_alreadyInQueueSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.AlreadyInQueue;
|
2012-08-07 08:24:15 +03:00
|
|
|
|
2012-02-07 08:08:07 +03:00
|
|
|
logger.Debug("Episode {0} is needed", subject);
|
2012-04-20 09:42:13 +03:00
|
|
|
return ReportRejectionType.None;
|
2012-02-07 08:08:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|