mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Renamed AiredAfter to CustomStartDate
This commit is contained in:
parent
15e4a286d1
commit
a7a0a25029
21 changed files with 93 additions and 71 deletions
|
@ -0,0 +1,44 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue