mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-25 22:46:31 -04:00
da29de4cfe
Closes #7725
46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using NLog;
|
|
using NzbDrone.Core.DataAugmentation.Scene;
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|
{
|
|
public class SeasonMatchSpecification : IDownloadDecisionEngineSpecification
|
|
{
|
|
private readonly Logger _logger;
|
|
private readonly ISceneMappingService _sceneMappingService;
|
|
|
|
public SeasonMatchSpecification(ISceneMappingService sceneMappingService, Logger logger)
|
|
{
|
|
_logger = logger;
|
|
_sceneMappingService = sceneMappingService;
|
|
}
|
|
|
|
public SpecificationPriority Priority => SpecificationPriority.Default;
|
|
public RejectionType Type => RejectionType.Permanent;
|
|
|
|
public DownloadSpecDecision IsSatisfiedBy(RemoteEpisode remoteEpisode, ReleaseDecisionInformation information)
|
|
{
|
|
if (information.SearchCriteria == null)
|
|
{
|
|
return DownloadSpecDecision.Accept();
|
|
}
|
|
|
|
var singleEpisodeSpec = information.SearchCriteria as SeasonSearchCriteria;
|
|
|
|
if (singleEpisodeSpec == null)
|
|
{
|
|
return DownloadSpecDecision.Accept();
|
|
}
|
|
|
|
if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber)
|
|
{
|
|
_logger.Debug("Season number does not match searched season number, skipping.");
|
|
return DownloadSpecDecision.Reject(DownloadRejectionReason.WrongSeason, "Wrong season");
|
|
}
|
|
|
|
return DownloadSpecDecision.Accept();
|
|
}
|
|
}
|
|
}
|