1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-21 01:49:57 +02:00
Sonarr/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs

50 lines
1.3 KiB
C#
Raw Normal View History

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