|
|
@ -17,17 +17,14 @@ namespace Radarr.Api.V3.Config
|
|
|
|
private readonly INamingConfigService _namingConfigService;
|
|
|
|
private readonly INamingConfigService _namingConfigService;
|
|
|
|
private readonly IFilenameSampleService _filenameSampleService;
|
|
|
|
private readonly IFilenameSampleService _filenameSampleService;
|
|
|
|
private readonly IFilenameValidationService _filenameValidationService;
|
|
|
|
private readonly IFilenameValidationService _filenameValidationService;
|
|
|
|
private readonly IBuildFileNames _filenameBuilder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public NamingConfigController(INamingConfigService namingConfigService,
|
|
|
|
public NamingConfigController(INamingConfigService namingConfigService,
|
|
|
|
IFilenameSampleService filenameSampleService,
|
|
|
|
IFilenameSampleService filenameSampleService,
|
|
|
|
IFilenameValidationService filenameValidationService,
|
|
|
|
IFilenameValidationService filenameValidationService)
|
|
|
|
IBuildFileNames filenameBuilder)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_namingConfigService = namingConfigService;
|
|
|
|
_namingConfigService = namingConfigService;
|
|
|
|
_filenameSampleService = filenameSampleService;
|
|
|
|
_filenameSampleService = filenameSampleService;
|
|
|
|
_filenameValidationService = filenameValidationService;
|
|
|
|
_filenameValidationService = filenameValidationService;
|
|
|
|
_filenameBuilder = filenameBuilder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SharedValidator.RuleFor(c => c.StandardMovieFormat).ValidMovieFormat();
|
|
|
|
SharedValidator.RuleFor(c => c.StandardMovieFormat).ValidMovieFormat();
|
|
|
|
SharedValidator.RuleFor(c => c.MovieFolderFormat).ValidMovieFolderFormat();
|
|
|
|
SharedValidator.RuleFor(c => c.MovieFolderFormat).ValidMovieFolderFormat();
|
|
|
@ -72,11 +69,11 @@ namespace Radarr.Api.V3.Config
|
|
|
|
var movieSampleResult = _filenameSampleService.GetMovieSample(nameSpec);
|
|
|
|
var movieSampleResult = _filenameSampleService.GetMovieSample(nameSpec);
|
|
|
|
|
|
|
|
|
|
|
|
sampleResource.MovieExample = nameSpec.StandardMovieFormat.IsNullOrWhiteSpace()
|
|
|
|
sampleResource.MovieExample = nameSpec.StandardMovieFormat.IsNullOrWhiteSpace()
|
|
|
|
? "Invalid Format"
|
|
|
|
? null
|
|
|
|
: movieSampleResult.FileName;
|
|
|
|
: movieSampleResult.FileName;
|
|
|
|
|
|
|
|
|
|
|
|
sampleResource.MovieFolderExample = nameSpec.MovieFolderFormat.IsNullOrWhiteSpace()
|
|
|
|
sampleResource.MovieFolderExample = nameSpec.MovieFolderFormat.IsNullOrWhiteSpace()
|
|
|
|
? "Invalid format"
|
|
|
|
? null
|
|
|
|
: _filenameSampleService.GetMovieFolderSample(nameSpec);
|
|
|
|
: _filenameSampleService.GetMovieFolderSample(nameSpec);
|
|
|
|
|
|
|
|
|
|
|
|
return sampleResource;
|
|
|
|
return sampleResource;
|
|
|
@ -90,6 +87,8 @@ namespace Radarr.Api.V3.Config
|
|
|
|
|
|
|
|
|
|
|
|
var validationFailures = new List<ValidationFailure>();
|
|
|
|
var validationFailures = new List<ValidationFailure>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
validationFailures.AddIfNotNull(standardMovieValidationResult);
|
|
|
|
|
|
|
|
|
|
|
|
if (validationFailures.Any())
|
|
|
|
if (validationFailures.Any())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new ValidationException(validationFailures.DistinctBy(v => v.PropertyName).ToArray());
|
|
|
|
throw new ValidationException(validationFailures.DistinctBy(v => v.PropertyName).ToArray());
|
|
|
|