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.
47 lines
1.4 KiB
47 lines
1.4 KiB
12 years ago
|
using System.Linq;
|
||
12 years ago
|
using NLog;
|
||
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
||
|
using NzbDrone.Core.Model;
|
||
12 years ago
|
using NzbDrone.Core.Parser;
|
||
|
using NzbDrone.Core.Parser.Model;
|
||
12 years ago
|
|
||
|
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
||
|
{
|
||
12 years ago
|
public class SingleEpisodeSearchMatchSpecification : IDecisionEngineSearchSpecification
|
||
12 years ago
|
{
|
||
|
private readonly Logger _logger;
|
||
|
|
||
12 years ago
|
public SingleEpisodeSearchMatchSpecification(Logger logger)
|
||
12 years ago
|
{
|
||
|
_logger = logger;
|
||
|
}
|
||
|
|
||
|
public string RejectionReason
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return "Episode doesn't match";
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchDefinitionBase searchDefinitionBase)
|
||
12 years ago
|
{
|
||
|
var singleEpisodeSpec = searchDefinitionBase as SingleEpisodeSearchDefinition;
|
||
|
if (singleEpisodeSpec == null) return true;
|
||
|
|
||
12 years ago
|
if (singleEpisodeSpec.SeasonNumber != remoteEpisode.SeasonNumber)
|
||
12 years ago
|
{
|
||
|
_logger.Trace("Season number does not match searched season number, skipping.");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
12 years ago
|
if (!remoteEpisode.Episodes.Select(c => c.EpisodeNumber).Contains(singleEpisodeSpec.EpisodeNumber))
|
||
12 years ago
|
{
|
||
|
_logger.Trace("Episode number does not match searched episode number, skipping.");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|