mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 10:05:58 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7dd01234b6 | ||
|
|
8f38abcf3a | ||
|
|
fc4e80ead0 | ||
|
|
e81b06f6fa | ||
|
|
dc770c9325 | ||
|
|
471255a09b | ||
|
|
9c8315aec7 | ||
|
|
a075dfb27c |
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -92,11 +92,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
timezoneWindows: "Berlin Standard Time"
|
timezoneWindows: "Berlin Standard Time"
|
||||||
|
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@v4.7.0
|
uses: actions/setup-java@v4.7.0
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup workspace
|
- name: Setup workspace
|
||||||
run: mkdir artifacts
|
run: mkdir artifacts
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
mkvtoolnix: C:\Program Files\MKVToolNix
|
|
||||||
library: X:/Files
|
|
||||||
|
|
||||||
attribute-config:
|
|
||||||
1:
|
|
||||||
audio: ger
|
|
||||||
subtitle: OFF
|
|
||||||
2:
|
|
||||||
audio: eng
|
|
||||||
subtitle: ger
|
|
||||||
|
|
||||||
# Recommendations for data stored on HDDs, increase when using SSDs
|
|
||||||
#threads: 2
|
|
||||||
|
|
||||||
#forced-keywords: ["forced", "signs"]
|
|
||||||
#commentary-keywords: ["commentary", "director"]
|
|
||||||
#preferred-subtitles: ["unstyled"]
|
|
||||||
|
|
||||||
#exclude-directories:
|
|
||||||
# - "D:/Path/To/File.mkv"
|
|
||||||
# - "D:/Path/To/Directory"
|
|
||||||
|
|
||||||
# If pattern is negated, can be used to exclude files
|
|
||||||
#include-pattern: "regex"
|
|
||||||
|
|
||||||
# Only files newer than
|
|
||||||
#filter-date: 20.03.2021-10:11:12
|
|
||||||
|
|
||||||
safe-mode:
|
|
||||||
#coherent:
|
|
||||||
#force-coherent:
|
|
||||||
#only-new-files:
|
|
||||||
|
|
||||||
|
|
||||||
@@ -14,10 +14,6 @@
|
|||||||
<destName>${project.artifactId}.jar</destName>
|
<destName>${project.artifactId}.jar</destName>
|
||||||
<outputDirectory>/</outputDirectory>
|
<outputDirectory>/</outputDirectory>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
|
||||||
<source>${project.basedir}/config-template.yaml</source>
|
|
||||||
<outputDirectory>/</outputDirectory>
|
|
||||||
</file>
|
|
||||||
<file>
|
<file>
|
||||||
<source></source>
|
<source></source>
|
||||||
</file>
|
</file>
|
||||||
|
|||||||
@@ -39,16 +39,17 @@ public class MkvFileProcessor implements FileProcessor {
|
|||||||
Map<String, Object> jsonMap;
|
Map<String, Object> jsonMap;
|
||||||
List<FileAttribute> fileAttributes = new ArrayList<>();
|
List<FileAttribute> fileAttributes = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
String command = format("\"%s\"", Config.getInstance().getPathFor(MkvToolNix.MKV_MERGE));
|
String[] command = new String[]{
|
||||||
String[] arguments = new String[]{
|
Config.getInstance().getPathFor(MkvToolNix.MKV_MERGE),
|
||||||
command,
|
|
||||||
"--identify",
|
"--identify",
|
||||||
"--identification-format",
|
"--identification-format",
|
||||||
"json",
|
"json",
|
||||||
file.getAbsoluteFile().toString()
|
file.getAbsolutePath()
|
||||||
};
|
};
|
||||||
|
|
||||||
InputStream inputStream = Runtime.getRuntime().exec(arguments).getInputStream();
|
log.debug("{}", String.join(" ", command));
|
||||||
|
InputStream inputStream = Runtime.getRuntime().exec(command)
|
||||||
|
.getInputStream();
|
||||||
jsonMap = mapper.readValue(inputStream, Map.class);
|
jsonMap = mapper.readValue(inputStream, Map.class);
|
||||||
List<Map<String, Object>> tracks = (List<Map<String, Object>>) jsonMap.get("tracks");
|
List<Map<String, Object>> tracks = (List<Map<String, Object>>) jsonMap.get("tracks");
|
||||||
if (tracks == null) {
|
if (tracks == null) {
|
||||||
@@ -154,7 +155,7 @@ public class MkvFileProcessor implements FileProcessor {
|
|||||||
|
|
||||||
if (fileInfo.isAudioDifferent()) {
|
if (fileInfo.isAudioDifferent()) {
|
||||||
if (fileInfo.getExistingDefaultAudioLanes() != null && !fileInfo.getExistingDefaultAudioLanes().isEmpty()) {
|
if (fileInfo.getExistingDefaultAudioLanes() != null && !fileInfo.getExistingDefaultAudioLanes().isEmpty()) {
|
||||||
for (FileAttribute track: fileInfo.getExistingDefaultAudioLanes()) {
|
for (FileAttribute track : fileInfo.getExistingDefaultAudioLanes()) {
|
||||||
sb.append(format(DISABLE_DEFAULT_TRACK, track.getId()));
|
sb.append(format(DISABLE_DEFAULT_TRACK, track.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,14 +163,14 @@ public class MkvFileProcessor implements FileProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fileInfo.getExistingForcedAudioLanes().isEmpty()) {
|
if (!fileInfo.getExistingForcedAudioLanes().isEmpty()) {
|
||||||
for (FileAttribute track: fileInfo.getExistingForcedAudioLanes()) {
|
for (FileAttribute track : fileInfo.getExistingForcedAudioLanes()) {
|
||||||
sb.append(format(DISABLE_FORCED_TRACK, track.getId()));
|
sb.append(format(DISABLE_FORCED_TRACK, track.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileInfo.isSubtitleDifferent()) {
|
if (fileInfo.isSubtitleDifferent()) {
|
||||||
if (fileInfo.getExistingDefaultSubtitleLanes() != null && !fileInfo.getExistingDefaultSubtitleLanes().isEmpty()) {
|
if (fileInfo.getExistingDefaultSubtitleLanes() != null && !fileInfo.getExistingDefaultSubtitleLanes().isEmpty()) {
|
||||||
for (FileAttribute track: fileInfo.getExistingDefaultSubtitleLanes()) {
|
for (FileAttribute track : fileInfo.getExistingDefaultSubtitleLanes()) {
|
||||||
sb.append(format(DISABLE_DEFAULT_TRACK, track.getId()));
|
sb.append(format(DISABLE_DEFAULT_TRACK, track.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,7 +185,7 @@ public class MkvFileProcessor implements FileProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(sb.toString());
|
log.debug(sb.toString());
|
||||||
InputStream inputstream = Runtime.getRuntime().exec(sb.toString()).getInputStream();
|
InputStream inputstream = Runtime.getRuntime().exec(sb.toString()).getInputStream();
|
||||||
String output = IOUtils.toString(new InputStreamReader(inputstream));
|
String output = IOUtils.toString(new InputStreamReader(inputstream));
|
||||||
log.debug(output);
|
log.debug(output);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import me.tongfei.progressbar.ProgressBar;
|
|||||||
import me.tongfei.progressbar.ProgressBarBuilder;
|
import me.tongfei.progressbar.ProgressBarBuilder;
|
||||||
import me.tongfei.progressbar.ProgressBarStyle;
|
import me.tongfei.progressbar.ProgressBarStyle;
|
||||||
import net.harawata.appdirs.AppDirsFactory;
|
import net.harawata.appdirs.AppDirsFactory;
|
||||||
import picocli.CommandLine;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -100,6 +99,12 @@ public abstract class AttributeUpdaterKernel {
|
|||||||
FileInfoDto fileInfo = new FileInfoDto(file);
|
FileInfoDto fileInfo = new FileInfoDto(file);
|
||||||
List<FileAttribute> attributes = processor.loadAttributes(file);
|
List<FileAttribute> attributes = processor.loadAttributes(file);
|
||||||
|
|
||||||
|
if (attributes == null || attributes.isEmpty()) {
|
||||||
|
statistic.total();
|
||||||
|
statistic.failure();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<FileAttribute> nonForcedTracks = processor.retrieveNonForcedTracks(attributes);
|
List<FileAttribute> nonForcedTracks = processor.retrieveNonForcedTracks(attributes);
|
||||||
List<FileAttribute> nonCommentaryTracks = processor.retrieveNonCommentaryTracks(attributes);
|
List<FileAttribute> nonCommentaryTracks = processor.retrieveNonCommentaryTracks(attributes);
|
||||||
|
|
||||||
@@ -122,7 +127,7 @@ public abstract class AttributeUpdaterKernel {
|
|||||||
statistic.shouldChange();
|
statistic.shouldChange();
|
||||||
commitChange(fileInfoDto);
|
commitChange(fileInfoDto);
|
||||||
break;
|
break;
|
||||||
case UNABLE_TO_APPLY:
|
case NO_SUITABLE_CONFIG:
|
||||||
statistic.noSuitableConfigFound();
|
statistic.noSuitableConfigFound();
|
||||||
break;
|
break;
|
||||||
case ALREADY_SUITED:
|
case ALREADY_SUITED:
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ public class FileInfoDto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSubtitleOFF() {
|
private boolean isSubtitleOFF() {
|
||||||
return desiredDefaultSubtitleLane == null && "OFF".equals(matchedConfig.getSubtitleLanguage()) &&
|
return desiredDefaultSubtitleLane == null
|
||||||
(existingDefaultSubtitleLanes != null && !existingDefaultSubtitleLanes.isEmpty());
|
&& (matchedConfig != null && "OFF".equals(matchedConfig.getSubtitleLanguage()))
|
||||||
|
&& (existingDefaultSubtitleLanes != null && !existingDefaultSubtitleLanes.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areForcedTracksDifferent() {
|
public boolean areForcedTracksDifferent() {
|
||||||
@@ -50,7 +51,7 @@ public class FileInfoDto {
|
|||||||
|
|
||||||
public FileStatus getStatus() {
|
public FileStatus getStatus() {
|
||||||
if (isChangeNecessary()) return FileStatus.CHANGE_NECESSARY;
|
if (isChangeNecessary()) return FileStatus.CHANGE_NECESSARY;
|
||||||
if (isUnableToApplyConfig()) return FileStatus.UNABLE_TO_APPLY;
|
if (isUnableToApplyConfig()) return FileStatus.NO_SUITABLE_CONFIG;
|
||||||
if (isAlreadySuitable()) return FileStatus.ALREADY_SUITED;
|
if (isAlreadySuitable()) return FileStatus.ALREADY_SUITED;
|
||||||
return FileStatus.UNKNOWN;
|
return FileStatus.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.model;
|
|||||||
|
|
||||||
public enum FileStatus {
|
public enum FileStatus {
|
||||||
CHANGE_NECESSARY,
|
CHANGE_NECESSARY,
|
||||||
UNABLE_TO_APPLY,
|
NO_SUITABLE_CONFIG,
|
||||||
ALREADY_SUITED,
|
ALREADY_SUITED,
|
||||||
UNKNOWN;
|
UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ Configuration:
|
|||||||
Appenders:
|
Appenders:
|
||||||
RollingFile:
|
RollingFile:
|
||||||
name: FileAppender
|
name: FileAppender
|
||||||
fileName: /var/log/MKVAudioSubtitleChanger/application.log
|
fileName: ${sys:user.home}/.local/mkvaudiosubtitlechanger/logs/application.log
|
||||||
filePattern: /var/log/MKVAudioSubtitleChanger/archive/application-%d{yyyy-MM-dd}-%i.log.gz
|
filePattern: ${sys:user.home}/.local/mkvaudiosubtitlechanger/logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz
|
||||||
PatternLayout:
|
PatternLayout:
|
||||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %msg %n %throwable"
|
Pattern: "%d{DEFAULT} | %-5level | %thread | %msg %n %throwable"
|
||||||
ThresholdFilter:
|
ThresholdFilter:
|
||||||
|
|||||||
Reference in New Issue
Block a user