mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-19 21:46:50 -04:00
16ed68d5de
Fixes #7405
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using FluentValidation;
|
|
using NzbDrone.Core.Annotations;
|
|
using NzbDrone.Core.Parser;
|
|
using NzbDrone.Core.Parser.Model;
|
|
using NzbDrone.Core.Validation;
|
|
|
|
namespace NzbDrone.Core.CustomFormats
|
|
{
|
|
public class ResolutionSpecificationValidator : AbstractValidator<ResolutionSpecification>
|
|
{
|
|
public ResolutionSpecificationValidator()
|
|
{
|
|
RuleFor(c => c.Value).NotEmpty();
|
|
}
|
|
}
|
|
|
|
public class ResolutionSpecification : CustomFormatSpecificationBase
|
|
{
|
|
private static readonly ResolutionSpecificationValidator Validator = new ResolutionSpecificationValidator();
|
|
|
|
public override int Order => 6;
|
|
public override string ImplementationName => "Resolution";
|
|
|
|
[FieldDefinition(1, Label = "Resolution", Type = FieldType.Select, SelectOptions = typeof(Resolution))]
|
|
public int Value { get; set; }
|
|
|
|
protected override bool IsSatisfiedByWithoutNegate(ParsedMovieInfo movieInfo)
|
|
{
|
|
return (movieInfo?.Quality?.Quality?.Resolution ?? (int)Resolution.Unknown) == Value;
|
|
}
|
|
|
|
public override NzbDroneValidationResult Validate()
|
|
{
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
}
|
|
}
|
|
}
|