mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using NLog;
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
|
{
|
|
public class QualityAllowedByProfileSpecification : IDecisionEngineSpecification
|
|
{
|
|
private readonly Logger _logger;
|
|
|
|
public QualityAllowedByProfileSpecification(Logger logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public RejectionType Type => RejectionType.Permanent;
|
|
|
|
public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
|
|
{
|
|
_logger.Debug("Checking if report meets quality requirements. {0}", subject.ParsedMovieInfo.Quality);
|
|
var profile = subject.Movie.Profile.Value;
|
|
var qualityIndex = profile.GetIndex(subject.ParsedMovieInfo.Quality.Quality);
|
|
var qualityOrGroup = profile.Items[qualityIndex.Index];
|
|
|
|
if (!qualityOrGroup.Allowed)
|
|
{
|
|
_logger.Debug("Quality {0} rejected by Movie's quality profile", subject.ParsedMovieInfo.Quality);
|
|
return Decision.Reject("{0} is not wanted in profile", subject.ParsedMovieInfo.Quality.Quality);
|
|
}
|
|
|
|
return Decision.Accept();
|
|
}
|
|
}
|
|
}
|