mirror of
https://github.com/Radarr/Radarr
synced 2025-10-06 02:13:00 +02:00
New: Validation for movie file tokens in Movie Folder Format
This commit is contained in:
@@ -27,6 +27,7 @@ namespace NzbDrone.Core.Organizer
|
||||
{
|
||||
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
||||
ruleBuilder.SetValidator(new IllegalCharactersValidator());
|
||||
ruleBuilder.SetValidator(new IllegalMovieFolderTokensValidator());
|
||||
|
||||
return ruleBuilder.SetValidator(new ValidMovieFolderFormatValidator());
|
||||
}
|
||||
@@ -65,6 +66,30 @@ namespace NzbDrone.Core.Organizer
|
||||
}
|
||||
}
|
||||
|
||||
public class IllegalMovieFolderTokensValidator : PropertyValidator
|
||||
{
|
||||
protected override string GetDefaultMessageTemplate() => "Must not contain deprecated tokens derived from file properties: {tokens}";
|
||||
|
||||
protected override bool IsValid(PropertyValidatorContext context)
|
||||
{
|
||||
if (context.PropertyValue is not string value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var match = FileNameValidation.DeprecatedMovieFolderTokensRegex.Matches(value);
|
||||
|
||||
if (match.Any())
|
||||
{
|
||||
context.MessageFormatter.AppendArgument("tokens", string.Join(", ", match.Select(c => c.Value).ToArray()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class IllegalCharactersValidator : PropertyValidator
|
||||
{
|
||||
private static readonly char[] InvalidPathChars = Path.GetInvalidPathChars();
|
||||
|
Reference in New Issue
Block a user