Add config validator tests & Improve mkvtoolnix error logging & ConfigPathValidator

This commit is contained in:
2023-02-12 21:34:38 +01:00
parent 1d6098efc1
commit 51b4885e65
12 changed files with 239 additions and 59 deletions

View File

@@ -90,7 +90,7 @@ public class MkvFileProcessor implements FileProcessor {
return info;
}
private void detectDefaultTracks(FileInfoDto info, List<FileAttribute> attributes, List<FileAttribute> nonForcedTracks) {
protected void detectDefaultTracks(FileInfoDto info, List<FileAttribute> attributes, List<FileAttribute> nonForcedTracks) {
Set<FileAttribute> detectedForcedSubtitleLanes = new HashSet<>();
for (FileAttribute attribute : attributes) {
if (attribute.isDefaultTrack() && AUDIO.equals(attribute.getType()))
@@ -108,7 +108,7 @@ public class MkvFileProcessor implements FileProcessor {
);
}
private void detectDesiredTracks(FileInfoDto info, List<FileAttribute> nonForcedTracks, List<FileAttribute> nonCommentaryTracks) {
protected void detectDesiredTracks(FileInfoDto info, List<FileAttribute> nonForcedTracks, List<FileAttribute> nonCommentaryTracks) {
for (AttributeConfig config : Config.getInstance().getAttributeConfig()) {
FileAttribute desiredAudio = null;
FileAttribute desiredSubtitle = null;
@@ -127,7 +127,7 @@ public class MkvFileProcessor implements FileProcessor {
}
@Override
public void update(File file, FileInfoDto fileInfo) throws IOException {
public void update(File file, FileInfoDto fileInfo) throws IOException, RuntimeException {
StringBuilder sb = new StringBuilder();
sb.append(format("\"%s\" ", Config.getInstance().getPathFor(MkvToolNix.MKV_PROP_EDIT)));
sb.append(format("\"%s\" ", file.getAbsolutePath()));
@@ -154,6 +154,8 @@ public class MkvFileProcessor implements FileProcessor {
}
InputStream inputstream = Runtime.getRuntime().exec(sb.toString()).getInputStream();
log.debug(IOUtils.toString(new InputStreamReader(inputstream)));
String output = IOUtils.toString(new InputStreamReader(inputstream));
if (output.contains("Error")) throw new RuntimeException(output);
log.debug(output);
}
}