You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using Ninject;
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers.DecisionEngine
|
|
|
|
|
{
|
|
|
|
|
public class CustomStartDateSpecification
|
|
|
|
|
{
|
|
|
|
|
private readonly EpisodeProvider _episodeProvider;
|
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
public CustomStartDateSpecification(EpisodeProvider episodeProvider)
|
|
|
|
|
{
|
|
|
|
|
_episodeProvider = episodeProvider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CustomStartDateSpecification()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
|
|
|
|
{
|
|
|
|
|
if (!subject.Series.CustomStartDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
logger.Debug("{0} does not restrict downloads before date.", subject.Series.Title);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var episodes = _episodeProvider.GetEpisodesByParseResult(subject);
|
|
|
|
|
|
|
|
|
|
if (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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|