2012-02-07 05:08:07 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Model;
|
2012-04-20 06:42:13 +00:00
|
|
|
|
using NzbDrone.Core.Repository.Search;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
|
2013-02-19 02:19:38 +00:00
|
|
|
|
namespace NzbDrone.Core.DecisionEngine
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
|
|
|
|
public class AllowedDownloadSpecification
|
|
|
|
|
{
|
|
|
|
|
private readonly QualityAllowedByProfileSpecification _qualityAllowedByProfileSpecification;
|
|
|
|
|
private readonly UpgradeDiskSpecification _upgradeDiskSpecification;
|
|
|
|
|
private readonly AcceptableSizeSpecification _acceptableSizeSpecification;
|
|
|
|
|
private readonly AlreadyInQueueSpecification _alreadyInQueueSpecification;
|
2012-02-17 09:32:33 +00:00
|
|
|
|
private readonly RetentionSpecification _retentionSpecification;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
private readonly AllowedReleaseGroupSpecification _allowedReleaseGroupSpecification;
|
2012-09-20 15:37:40 +00:00
|
|
|
|
private readonly CustomStartDateSpecification _customStartDateSpecification;
|
2013-01-16 01:36:02 +00:00
|
|
|
|
private readonly LanguageSpecification _languageSpecification;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification,
|
|
|
|
|
UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification,
|
2012-08-07 05:24:15 +00:00
|
|
|
|
AlreadyInQueueSpecification alreadyInQueueSpecification, RetentionSpecification retentionSpecification,
|
2013-01-16 01:36:02 +00:00
|
|
|
|
AllowedReleaseGroupSpecification allowedReleaseGroupSpecification, CustomStartDateSpecification customStartDateSpecification,
|
|
|
|
|
LanguageSpecification languageSpecification)
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
|
|
|
|
_qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification;
|
|
|
|
|
_upgradeDiskSpecification = upgradeDiskSpecification;
|
|
|
|
|
_acceptableSizeSpecification = acceptableSizeSpecification;
|
|
|
|
|
_alreadyInQueueSpecification = alreadyInQueueSpecification;
|
2012-02-17 09:32:33 +00:00
|
|
|
|
_retentionSpecification = retentionSpecification;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
_allowedReleaseGroupSpecification = allowedReleaseGroupSpecification;
|
2012-09-20 15:37:40 +00:00
|
|
|
|
_customStartDateSpecification = customStartDateSpecification;
|
2013-01-16 01:36:02 +00:00
|
|
|
|
_languageSpecification = languageSpecification;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AllowedDownloadSpecification()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-06 20:30:53 +00:00
|
|
|
|
public virtual ReportRejectionReasons IsSatisfiedBy(EpisodeParseResult subject)
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2013-03-06 20:30:53 +00:00
|
|
|
|
if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.QualityNotWanted;
|
|
|
|
|
if (!_customStartDateSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.AiredAfterCustomStartDate;
|
|
|
|
|
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.ExistingQualityIsEqualOrBetter;
|
|
|
|
|
if (!_languageSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.LanguageNotWanted;
|
|
|
|
|
if (!_retentionSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.Retention;
|
|
|
|
|
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.Size;
|
|
|
|
|
if (!_allowedReleaseGroupSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.ReleaseGroupNotWanted;
|
|
|
|
|
if (_alreadyInQueueSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.AlreadyInQueue;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
|
2012-02-07 05:08:07 +00:00
|
|
|
|
logger.Debug("Episode {0} is needed", subject);
|
2013-03-06 20:30:53 +00:00
|
|
|
|
return ReportRejectionReasons.None;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|