2013-03-07 00:19:49 +00:00
|
|
|
using System.Linq;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
|
|
|
{
|
2013-04-07 07:30:37 +00:00
|
|
|
public class CustomStartDateSpecification : IDecisionEngineSpecification
|
2013-03-07 00:19:49 +00:00
|
|
|
{
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
public CustomStartDateSpecification(Logger logger)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string RejectionReason
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return "Aired before configured cut-off";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-07 19:01:24 +00:00
|
|
|
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
|
2013-03-07 00:19:49 +00:00
|
|
|
{
|
|
|
|
if (!subject.Series.CustomStartDate.HasValue)
|
|
|
|
{
|
|
|
|
_logger.Debug("{0} does not restrict downloads before date.", subject.Series.Title);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (subject.Episodes.Any(episode => episode.AirDate >= subject.Series.CustomStartDate.Value))
|
|
|
|
{
|
|
|
|
_logger.Debug("One or more episodes aired after cutoff, downloading.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_logger.Debug("Episodes aired before cutoff date: {0}", subject.Series.CustomStartDate);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|