(cherry picked from commit 2a7964bc16fa32bc0000bb7326795d02cc41bfed)sonarr-pull-2a7964bc
parent
98ae377aff
commit
e76974a0b3
@ -0,0 +1,37 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using NzbDrone.Core.Annotations;
|
||||||
|
using NzbDrone.Core.Languages;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.AutoTagging.Specifications
|
||||||
|
{
|
||||||
|
public class OriginalLanguageSpecificationValidator : AbstractValidator<OriginalLanguageSpecification>
|
||||||
|
{
|
||||||
|
public OriginalLanguageSpecificationValidator()
|
||||||
|
{
|
||||||
|
RuleFor(c => c.Value).GreaterThanOrEqualTo(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OriginalLanguageSpecification : AutoTaggingSpecificationBase
|
||||||
|
{
|
||||||
|
private static readonly OriginalLanguageSpecificationValidator Validator = new ();
|
||||||
|
|
||||||
|
public override int Order => 1;
|
||||||
|
public override string ImplementationName => "Original Language";
|
||||||
|
|
||||||
|
[FieldDefinition(1, Label = "Language", Type = FieldType.Select, SelectOptions = typeof(OriginalLanguageFieldConverter))]
|
||||||
|
public int Value { get; set; }
|
||||||
|
|
||||||
|
protected override bool IsSatisfiedByWithoutNegate(Series series)
|
||||||
|
{
|
||||||
|
return Value == series.OriginalLanguage.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override NzbDroneValidationResult Validate()
|
||||||
|
{
|
||||||
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Core.Annotations;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Languages
|
||||||
|
{
|
||||||
|
public class OriginalLanguageFieldConverter : ISelectOptionsConverter
|
||||||
|
{
|
||||||
|
public List<SelectOption> GetSelectOptions()
|
||||||
|
{
|
||||||
|
return Language.All
|
||||||
|
.Where(l => l.Id >= 0)
|
||||||
|
.OrderBy(l => l.Id > 0).ThenBy(l => l.Name)
|
||||||
|
.ToList()
|
||||||
|
.ConvertAll(v => new SelectOption { Value = v.Id, Name = v.Name });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue