mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Add support for multiple library paths
This commit is contained in:
@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import me.tongfei.progressbar.ProgressBarBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -25,7 +26,9 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
|
||||
}
|
||||
|
||||
protected List<File> getFiles() {
|
||||
return fileProcessor.loadDirectory(config.getLibraryPath().getPath(), config.getCoherent());
|
||||
return Arrays.stream(config.getLibraryPaths())
|
||||
.flatMap(path -> fileProcessor.loadDirectory(path.getPath(), config.getCoherent()).stream())
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import me.tongfei.progressbar.ProgressBarBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@@ -23,7 +24,9 @@ public class SingleFileAttributeUpdater extends AttributeUpdater {
|
||||
|
||||
@Override
|
||||
protected List<File> getFiles() {
|
||||
return fileProcessor.loadFiles(config.getLibraryPath().getPath());
|
||||
return Arrays.stream(config.getLibraryPaths())
|
||||
.flatMap(path -> fileProcessor.loadFiles(path.getPath()).stream())
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,14 +4,15 @@ import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ValidFileValidator implements ConstraintValidator<ValidFile, File> {
|
||||
public class ValidFileValidator implements ConstraintValidator<ValidFile, File[]> {
|
||||
@Override
|
||||
public void initialize(ValidFile constraintAnnotation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(File file, ConstraintValidatorContext context) {
|
||||
return file != null && file.exists();
|
||||
public boolean isValid(File[] files, ConstraintValidatorContext context) {
|
||||
return files != null && files.length > 0 && Arrays.stream(files).allMatch(File::exists);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ public class InputConfig implements CommandLine.IVersionProvider {
|
||||
CommandLine.Model.CommandSpec spec;
|
||||
|
||||
@ValidFile(message = "does not exist")
|
||||
@CommandLine.Parameters(description = "path to library")
|
||||
private File libraryPath;
|
||||
@CommandLine.Parameters(description = "paths to library", arity = "1..*")
|
||||
private File[] libraryPaths;
|
||||
|
||||
@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=" + libraryPath)
|
||||
.add("libraryPath=" + libraryPaths)
|
||||
.add("attributeConfig=" + Arrays.toString(attributeConfig))
|
||||
.add("mkvToolNix=" + mkvToolNix)
|
||||
.add("safeMode=" + safeMode)
|
||||
|
||||
Reference in New Issue
Block a user