2013-03-07 00:19:49 +00:00
|
|
|
using System.Linq;
|
2012-02-07 05:08:07 +00:00
|
|
|
using NLog;
|
2013-08-07 03:18:05 +00:00
|
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
2013-04-15 01:41:39 +00:00
|
|
|
using NzbDrone.Core.Parser.Model;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
2013-08-07 03:18:05 +00:00
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
2013-04-07 07:30:37 +00:00
|
|
|
public class MonitoredEpisodeSpecification : IDecisionEngineSpecification
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
2013-03-07 00:19:49 +00:00
|
|
|
private readonly Logger _logger;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
2013-06-09 06:21:32 +00:00
|
|
|
public MonitoredEpisodeSpecification(Logger logger)
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
2013-03-07 00:19:49 +00:00
|
|
|
_logger = logger;
|
2012-02-07 05:08:07 +00:00
|
|
|
}
|
|
|
|
|
2013-03-07 00:19:49 +00:00
|
|
|
public string RejectionReason
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
2013-03-07 00:19:49 +00:00
|
|
|
get
|
|
|
|
{
|
2013-07-09 01:22:02 +00:00
|
|
|
return "Series or Episode is not monitored";
|
2013-03-07 00:19:49 +00:00
|
|
|
}
|
2012-02-07 05:08:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 03:30:20 +00:00
|
|
|
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
2013-08-08 03:30:20 +00:00
|
|
|
if (searchCriteria != null)
|
2013-08-07 03:18:05 +00:00
|
|
|
{
|
|
|
|
_logger.Trace("Skipping monitored check during search");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-15 01:41:39 +00:00
|
|
|
if (!subject.Series.Monitored)
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
2013-07-05 05:17:25 +00:00
|
|
|
_logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Series);
|
2012-02-07 05:08:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//return monitored if any of the episodes are monitored
|
2013-07-09 01:22:02 +00:00
|
|
|
if (subject.Episodes.Any(episode => episode.Monitored))
|
2012-02-07 05:08:07 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:22:02 +00:00
|
|
|
_logger.Debug("No episodes are monitored. skipping.");
|
2012-02-07 05:08:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|