1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2025-03-03 10:06:06 +00:00
Lidarr/NzbDrone.Core/Providers/DecisionEngine/CustomStartDateSpecification.cs
Mark McDowall 9c6d78d479 Cleanup and updates for XEM
SceneSource added to signify to lookup via scene name
Use Episodes for naming instead of EpisodeNumbers (in ParseResult)
2012-10-17 00:39:06 -07:00

42 lines
1.2 KiB
C#

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;
}
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;
}
}
}