2013-04-07 07:30:37 +00:00
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
2013-04-15 01:41:39 +00:00
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-04-07 07:30:37 +00:00
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|
|
|
{
|
|
|
|
public class DailyEpisodeMatchSpecification : IDecisionEngineSearchSpecification
|
|
|
|
{
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly IEpisodeService _episodeService;
|
|
|
|
|
|
|
|
public DailyEpisodeMatchSpecification(Logger logger, IEpisodeService episodeService)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
_episodeService = episodeService;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string RejectionReason
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return "Episode doesn't match";
|
|
|
|
}
|
|
|
|
}
|
2013-06-06 14:42:23 +00:00
|
|
|
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase)
|
2013-04-07 07:30:37 +00:00
|
|
|
{
|
2013-06-06 14:42:23 +00:00
|
|
|
var dailySearchSpec = searchCriteriaBase as DailyEpisodeSearchCriteria;
|
2013-04-07 07:30:37 +00:00
|
|
|
|
|
|
|
if (dailySearchSpec == null) return true;
|
|
|
|
|
|
|
|
var episode = _episodeService.GetEpisode(dailySearchSpec.SeriesId, dailySearchSpec.Airtime);
|
|
|
|
|
2013-04-28 19:46:13 +00:00
|
|
|
if (!remoteEpisode.ParsedEpisodeInfo.AirDate.HasValue || remoteEpisode.ParsedEpisodeInfo.AirDate.Value.Date != episode.AirDate.Value.Date)
|
2013-04-07 07:30:37 +00:00
|
|
|
{
|
|
|
|
_logger.Trace("Episode AirDate does not match searched episode number, skipping.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|