You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
61 lines
1.8 KiB
12 years ago
|
using System.Linq;
|
||
13 years ago
|
using NLog;
|
||
|
using NzbDrone.Core.Model;
|
||
12 years ago
|
using NzbDrone.Core.Tv;
|
||
13 years ago
|
|
||
12 years ago
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||
13 years ago
|
{
|
||
12 years ago
|
public class MonitoredEpisodeSpecification : IFetchableSpecification
|
||
13 years ago
|
{
|
||
12 years ago
|
private readonly IEpisodeService _episodeService;
|
||
12 years ago
|
private readonly ISeriesRepository _seriesRepository;
|
||
12 years ago
|
private readonly Logger _logger;
|
||
13 years ago
|
|
||
12 years ago
|
public MonitoredEpisodeSpecification(IEpisodeService episodeService, ISeriesRepository seriesRepository, Logger logger)
|
||
13 years ago
|
{
|
||
12 years ago
|
_episodeService = episodeService;
|
||
12 years ago
|
_seriesRepository = seriesRepository;
|
||
12 years ago
|
_logger = logger;
|
||
13 years ago
|
}
|
||
|
|
||
12 years ago
|
public string RejectionReason
|
||
13 years ago
|
{
|
||
12 years ago
|
get
|
||
|
{
|
||
|
return "Series is not monitored";
|
||
|
}
|
||
13 years ago
|
}
|
||
|
|
||
|
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||
|
{
|
||
12 years ago
|
var series = _seriesRepository.GetByTitle(subject.CleanTitle);
|
||
13 years ago
|
|
||
|
if (series == null)
|
||
|
{
|
||
12 years ago
|
_logger.Trace("{0} is not mapped to any series in DB. skipping", subject.CleanTitle);
|
||
13 years ago
|
return false;
|
||
|
}
|
||
|
|
||
|
subject.Series = series;
|
||
|
|
||
|
if (!series.Monitored)
|
||
|
{
|
||
12 years ago
|
_logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.CleanTitle);
|
||
13 years ago
|
return false;
|
||
|
}
|
||
|
|
||
12 years ago
|
var episodes = _episodeService.GetEpisodesByParseResult(subject);
|
||
12 years ago
|
subject.Episodes = episodes;
|
||
13 years ago
|
|
||
|
//return monitored if any of the episodes are monitored
|
||
|
if (episodes.Any(episode => !episode.Ignored))
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
12 years ago
|
_logger.Debug("All episodes are ignored. skipping.");
|
||
13 years ago
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|