mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using NLog;
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
using NzbDrone.Core.Model;
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|
{
|
|
public class SingleEpisodeMatchSpecification : IDecisionEngineSearchSpecification
|
|
{
|
|
private readonly Logger _logger;
|
|
|
|
public SingleEpisodeMatchSpecification(Logger logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public string RejectionReason
|
|
{
|
|
get
|
|
{
|
|
return "Episode doesn't match";
|
|
}
|
|
}
|
|
|
|
public bool IsSatisfiedBy(IndexerParseResult indexerParseResult, SearchDefinitionBase searchDefinitionBase)
|
|
{
|
|
var singleEpisodeSpec = searchDefinitionBase as SingleEpisodeSearchDefinition;
|
|
if (singleEpisodeSpec == null) return true;
|
|
|
|
if (singleEpisodeSpec.SeasonNumber != indexerParseResult.SeasonNumber)
|
|
{
|
|
_logger.Trace("Season number does not match searched season number, skipping.");
|
|
return false;
|
|
}
|
|
|
|
if (!indexerParseResult.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber))
|
|
{
|
|
_logger.Trace("Episode number does not match searched episode number, skipping.");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
} |