mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 10:05:58 +01:00
Add support for multiple library paths
This commit is contained in:
@@ -26,7 +26,7 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
|
||||
}
|
||||
|
||||
protected List<File> getFiles() {
|
||||
return Arrays.stream(config.getLibraryPaths())
|
||||
return Arrays.stream(config.getLibraryPath())
|
||||
.flatMap(path -> fileProcessor.loadDirectory(path.getPath(), config.getCoherent()).stream())
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SingleFileAttributeUpdater extends AttributeUpdater {
|
||||
|
||||
@Override
|
||||
protected List<File> getFiles() {
|
||||
return Arrays.stream(config.getLibraryPaths())
|
||||
return Arrays.stream(config.getLibraryPath())
|
||||
.flatMap(path -> fileProcessor.loadFiles(path.getPath()).stream())
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.validation;
|
||||
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Slf4j
|
||||
public class ValidFileValidator implements ConstraintValidator<ValidFile, File[]> {
|
||||
@Override
|
||||
public void initialize(ValidFile constraintAnnotation) {
|
||||
@@ -13,6 +15,13 @@ public class ValidFileValidator implements ConstraintValidator<ValidFile, File[]
|
||||
|
||||
@Override
|
||||
public boolean isValid(File[] files, ConstraintValidatorContext context) {
|
||||
return files != null && files.length > 0 && Arrays.stream(files).allMatch(File::exists);
|
||||
if (files == null || files.length == 0) return false;
|
||||
for (File file: files) {
|
||||
if (!file.exists()) {
|
||||
log.error("{} does not exist", file.getPath());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class InputConfig implements CommandLine.IVersionProvider {
|
||||
|
||||
@ValidFile(message = "does not exist")
|
||||
@CommandLine.Parameters(description = "paths to library", arity = "1..*")
|
||||
private File[] libraryPaths;
|
||||
private File[] libraryPath;
|
||||
|
||||
@Option(names = {"-a", "--attribute-config"}, arity = "1..*", converter = AttributeConfigConverter.class,
|
||||
description = "List of audio:subtitle pairs for matching defaults in order (e.g. jpn:eng jpn:ger)")
|
||||
@@ -91,7 +91,7 @@ public class InputConfig implements CommandLine.IVersionProvider {
|
||||
return new StringJoiner(", ", InputConfig.class.getSimpleName() + "[", "]")
|
||||
.add("configPath=" + configPath)
|
||||
.add("spec=" + spec)
|
||||
.add("libraryPath=" + libraryPaths)
|
||||
.add("libraryPath=" + libraryPath)
|
||||
.add("attributeConfig=" + Arrays.toString(attributeConfig))
|
||||
.add("mkvToolNix=" + mkvToolNix)
|
||||
.add("safeMode=" + safeMode)
|
||||
|
||||
Reference in New Issue
Block a user