You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using FluentValidation;
|
|
using NzbDrone.Common.Extensions;
|
|
using NzbDrone.Core.Annotations;
|
|
using NzbDrone.Core.Music;
|
|
using NzbDrone.Core.Validation;
|
|
|
|
namespace NzbDrone.Core.AutoTagging.Specifications
|
|
{
|
|
public class GenreSpecificationValidator : AbstractValidator<GenreSpecification>
|
|
{
|
|
public GenreSpecificationValidator()
|
|
{
|
|
RuleFor(c => c.Value).NotEmpty();
|
|
}
|
|
}
|
|
|
|
public class GenreSpecification : AutoTaggingSpecificationBase
|
|
{
|
|
private static readonly GenreSpecificationValidator Validator = new GenreSpecificationValidator();
|
|
|
|
public override int Order => 1;
|
|
public override string ImplementationName => "Genre";
|
|
|
|
[FieldDefinition(1, Label = "Genre(s)", Type = FieldType.Tag)]
|
|
public IEnumerable<string> Value { get; set; }
|
|
|
|
protected override bool IsSatisfiedByWithoutNegate(Artist artist)
|
|
{
|
|
return artist?.Metadata?.Value?.Genres.Any(genre => Value.ContainsIgnoreCase(genre)) ?? false;
|
|
}
|
|
|
|
public override NzbDroneValidationResult Validate()
|
|
{
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
}
|
|
}
|
|
}
|