mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-21 22:05:43 -04:00
New: Improve multi-language negate Custom Format
(cherry picked from commit 42b11528b4699b8343887185c93a02b139192d83) Closes #9720
This commit is contained in:
@@ -30,6 +30,16 @@ namespace NzbDrone.Core.CustomFormats
|
||||
[FieldDefinition(1, Label = "Language", Type = FieldType.Select, SelectOptions = typeof(LanguageFieldConverter))]
|
||||
public int Value { get; set; }
|
||||
|
||||
public override bool IsSatisfiedBy(CustomFormatInput input)
|
||||
{
|
||||
if (Negate)
|
||||
{
|
||||
return IsSatisfiedByWithNegate(input);
|
||||
}
|
||||
|
||||
return IsSatisfiedByWithoutNegate(input);
|
||||
}
|
||||
|
||||
protected override bool IsSatisfiedByWithoutNegate(CustomFormatInput input)
|
||||
{
|
||||
var comparedLanguage = input.MovieInfo != null && input.Movie != null && Value == Language.Original.Id && input.Movie.MovieMetadata.Value.OriginalLanguage != Language.Unknown
|
||||
@@ -39,6 +49,15 @@ namespace NzbDrone.Core.CustomFormats
|
||||
return input?.Languages?.Contains(comparedLanguage) ?? false;
|
||||
}
|
||||
|
||||
private bool IsSatisfiedByWithNegate(CustomFormatInput input)
|
||||
{
|
||||
var comparedLanguage = input.MovieInfo != null && input.Movie != null && Value == Language.Original.Id && input.Movie.MovieMetadata.Value.OriginalLanguage != Language.Unknown
|
||||
? input.Movie.MovieMetadata.Value.OriginalLanguage
|
||||
: (Language)Value;
|
||||
|
||||
return !input.Languages?.Contains(comparedLanguage) ?? false;
|
||||
}
|
||||
|
||||
public override NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
|
||||
Reference in New Issue
Block a user