2013-03-07 03:19:49 +03:00
|
|
|
using System.Linq;
|
2012-02-07 08:08:07 +03:00
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Core.Model;
|
2013-04-15 04:41:39 +03:00
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-03-07 03:19:49 +03:00
|
|
|
using NzbDrone.Core.Tv;
|
2012-02-07 08:08:07 +03:00
|
|
|
|
2013-03-07 03:19:49 +03:00
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
2013-04-07 10:30:37 +03:00
|
|
|
public class MonitoredEpisodeSpecification : IDecisionEngineSpecification
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
2013-02-22 03:47:09 +03:00
|
|
|
private readonly IEpisodeService _episodeService;
|
2013-02-19 09:56:02 +03:00
|
|
|
private readonly ISeriesRepository _seriesRepository;
|
2013-03-07 03:19:49 +03:00
|
|
|
private readonly Logger _logger;
|
2012-02-07 08:08:07 +03:00
|
|
|
|
2013-03-07 03:19:49 +03:00
|
|
|
public MonitoredEpisodeSpecification(IEpisodeService episodeService, ISeriesRepository seriesRepository, Logger logger)
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
2013-02-20 05:05:15 +03:00
|
|
|
_episodeService = episodeService;
|
2013-02-19 09:56:02 +03:00
|
|
|
_seriesRepository = seriesRepository;
|
2013-03-07 03:19:49 +03:00
|
|
|
_logger = logger;
|
2012-02-07 08:08:07 +03:00
|
|
|
}
|
|
|
|
|
2013-03-07 03:19:49 +03:00
|
|
|
public string RejectionReason
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
2013-03-07 03:19:49 +03:00
|
|
|
get
|
|
|
|
{
|
|
|
|
return "Series is not monitored";
|
|
|
|
}
|
2012-02-07 08:08:07 +03:00
|
|
|
}
|
|
|
|
|
2013-04-15 04:41:39 +03:00
|
|
|
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
2013-04-15 04:41:39 +03:00
|
|
|
if (!subject.Series.Monitored)
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
2013-04-15 04:41:39 +03:00
|
|
|
_logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Series.Title);
|
2012-02-07 08:08:07 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//return monitored if any of the episodes are monitored
|
2013-04-15 04:41:39 +03:00
|
|
|
if (subject.Episodes.Any(episode => !episode.Ignored))
|
2012-02-07 08:08:07 +03:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-07 03:19:49 +03:00
|
|
|
_logger.Debug("All episodes are ignored. skipping.");
|
2012-02-07 08:08:07 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|