diff --git a/src/NzbDrone.Core/AutoTagging/Specifications/StatusSpecification.cs b/src/NzbDrone.Core/AutoTagging/Specifications/StatusSpecification.cs new file mode 100644 index 000000000..e161bc21b --- /dev/null +++ b/src/NzbDrone.Core/AutoTagging/Specifications/StatusSpecification.cs @@ -0,0 +1,43 @@ +using System; +using FluentValidation; +using NzbDrone.Core.Annotations; +using NzbDrone.Core.Movies; +using NzbDrone.Core.Validation; + +namespace NzbDrone.Core.AutoTagging.Specifications +{ + public class StatusSpecificationValidator : AbstractValidator + { + public StatusSpecificationValidator() + { + RuleFor(c => c.Status).Custom((statusType, context) => + { + if (!Enum.IsDefined(typeof(MovieStatusType), statusType)) + { + context.AddFailure($"Invalid status type condition value: {statusType}"); + } + }); + } + } + + public class StatusSpecification : AutoTaggingSpecificationBase + { + private static readonly StatusSpecificationValidator Validator = new (); + + public override int Order => 1; + public override string ImplementationName => "Status"; + + [FieldDefinition(1, Label = "AutoTaggingSpecificationStatus", Type = FieldType.Select, SelectOptions = typeof(MovieStatusType))] + public int Status { get; set; } + + protected override bool IsSatisfiedByWithoutNegate(Movie movie) + { + return movie?.MovieMetadata?.Value?.Status == (MovieStatusType)Status; + } + + public override NzbDroneValidationResult Validate() + { + return new NzbDroneValidationResult(Validator.Validate(this)); + } + } +} diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index a86df4f69..71da4174a 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -124,6 +124,7 @@ "AutoTaggingSpecificationOriginalLanguage": "Language", "AutoTaggingSpecificationQualityProfile": "Quality Profile", "AutoTaggingSpecificationRootFolder": "Root Folder", + "AutoTaggingSpecificationStatus": "Status", "AutoTaggingSpecificationTag": "Tag", "AutoUnmonitorPreviouslyDownloadedMoviesHelpText": "Movies deleted from the disk are automatically unmonitored in {appName}", "Automatic": "Automatic",