mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3205969d3b | |||
| d24aedb0af | |||
| b86c7b98a5 | |||
|
|
69c192c08b | ||
|
|
7dd01234b6 | ||
|
|
8f38abcf3a | ||
|
|
fc4e80ead0 | ||
|
|
e81b06f6fa | ||
|
|
dc770c9325 | ||
|
|
471255a09b | ||
|
|
9c8315aec7 | ||
|
|
c33777b038 | ||
|
|
6c08ce69ea | ||
|
|
7f8c14e3a9 | ||
|
|
553c672e4d | ||
|
|
d98c4cd49e | ||
|
|
21f244ff3f | ||
|
|
a075dfb27c |
39
.github/workflows/release.yml
vendored
39
.github/workflows/release.yml
vendored
@@ -20,11 +20,11 @@ jobs:
|
||||
with:
|
||||
timezoneLinux: "Europe/Berlin"
|
||||
|
||||
- name: Set up JDK 21
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4.7.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
|
||||
- name: Setup workspace
|
||||
run: mkdir artifacts
|
||||
@@ -41,6 +41,41 @@ jobs:
|
||||
with:
|
||||
args: 'artifacts/M*'
|
||||
|
||||
debian-build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install mkvtoolnix
|
||||
run: sudo apt-get install -y mkvtoolnix
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set timezone
|
||||
uses: szenius/set-timezone@v2.0
|
||||
with:
|
||||
timezoneLinux: "Europe/Berlin"
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4.7.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
|
||||
- name: Setup workspace
|
||||
run: mkdir artifacts
|
||||
|
||||
- name: Build with Maven
|
||||
run: |
|
||||
mvn clean package --file pom.xml -P linux
|
||||
cp target/M*.deb artifacts/
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: skx/github-action-publish-binaries@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
args: 'artifacts/M*'
|
||||
|
||||
windows-installer-build:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
|
||||
@@ -12,13 +12,11 @@ A streamlined solution for managing MKV files, this program leverages MKVToolNix
|
||||
## Execution
|
||||
### Minimal usage
|
||||
Portable: `java -jar mkvaudiosubtitlechanger-<version>.jar --library "X:/Files" --attribute-config eng:ger eng:OFF`
|
||||
|
||||
Windows (installed): `mkvaudiosubtitlechanger.jar --library "X:/Files" --attribute-config eng:ger eng:OFF`
|
||||
Windows & Linux (installed): `mkvaudiosubtitlechanger --library "X:/Files" --attribute-config eng:ger eng:OFF`
|
||||
|
||||
### Safe usage (best for testing before applying to whole library)
|
||||
Portable: `java -jar mkvaudiosubtitlechanger-<version>.jar --library "X:/Files" --attribute-config eng:ger eng:OFF --safe-mode`
|
||||
|
||||
Windows (installed): `mkvaudiosubtitlechanger.jar --library "X:/Files" --attribute-config eng:ger eng:OFF --safe-mode`
|
||||
Windows & Linux (installed): `mkvaudiosubtitlechanger --library "X:/Files" --attribute-config eng:ger eng:OFF --safe-mode`
|
||||
|
||||
**Attribute-config must be entered in pairs: `audio:subtitle`; Example: `jpn:eng`. More about this topic
|
||||
[here](https://github.com/RatzzFatzz/MKVAudioSubtitleChanger/wiki/Attribute-Config).**
|
||||
@@ -33,6 +31,7 @@ Windows (installed): `mkvaudiosubtitlechanger.jar --library "X:/Files" --attribu
|
||||
Keywords to identify commentary tracks (Defaults will be overwritten; Default: commentary, director)
|
||||
-d, --filter-date=<filterDate>
|
||||
only consider files created newer than entered date (format: "dd.MM.yyyy-HH:mm:ss")
|
||||
--debug Enable debug logging
|
||||
-e, --excluded-directory=<excludedDirectories>...
|
||||
Directories to be excluded, combines with config file
|
||||
--forced-keywords=<forcedKeywords>[, <forcedKeywords>...]...
|
||||
@@ -53,7 +52,7 @@ Windows (installed): `mkvaudiosubtitlechanger.jar --library "X:/Files" --attribu
|
||||
```
|
||||
If you need more information how each parameter works, check out [this wiki page](https://github.com/RatzzFatzz/MKVAudioSubtitleChanger/wiki/Parameters-v4).
|
||||
|
||||
All parameters can also be defined in a [config file](https://github.com/RatzzFatzz/MKVAudioSubtitleChanger/wiki/How-to-config-file).
|
||||
All parameters can also be defined in a [config file](https://picocli.info/#_argument_files_for_long_command_lines).
|
||||
|
||||
## Build requirements
|
||||
- JDK 21 or newer
|
||||
|
||||
@@ -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>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>${project.basedir}/config-template.yaml</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source></source>
|
||||
</file>
|
||||
|
||||
195
pom.xml
195
pom.xml
@@ -6,11 +6,16 @@
|
||||
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>MKVAudioSubtitleChanger</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<version>4.0.2</version>
|
||||
|
||||
<properties>
|
||||
<mainClass>at.pcgamingfreaks.mkvaudiosubtitlechanger.Main</mainClass>
|
||||
|
||||
<project.maintainer>RatzzFatzz</project.maintainer>
|
||||
<project.maintainer.mail>github.contact@ratzloeffel.de</project.maintainer.mail>
|
||||
<project.description>Command-line utility for batch-managing default audio and subtitle tracks in MKV files.</project.description>
|
||||
|
||||
<java-version>17</java-version>
|
||||
<lombok-version>1.18.36</lombok-version>
|
||||
</properties>
|
||||
|
||||
@@ -22,8 +27,7 @@
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>log4j2.yml</include>
|
||||
<include>log4j2-debug.yml</include>
|
||||
<include>log4j2.yaml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
@@ -66,24 +70,70 @@
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-jpackage-input</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/jpackage-input</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<includes>
|
||||
<include>${project.artifactId}-${project.version}.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>filter-windows-installer-info</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/wix-resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/wix/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.panteleyev</groupId>
|
||||
<artifactId>jpackage-maven-plugin</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<configuration>
|
||||
<name>${project.artifactId}</name>
|
||||
<vendor>RatzzFatzz</vendor>
|
||||
<appVersion>${project.version}</appVersion>
|
||||
|
||||
<destination>target/installer</destination>
|
||||
|
||||
<input>target/jpackage-input</input>
|
||||
<mainClass>at.pcgamingfreaks.mkvaudiosubtitlechanger.Main</mainClass>
|
||||
<mainJar>${project.artifactId}-${project.version}.jar</mainJar>
|
||||
|
||||
<resourceDir>${project.build.directory}/wix-resources/</resourceDir>
|
||||
<type>EXE</type>
|
||||
<winConsole>true</winConsole>
|
||||
<winShortcut>false</winShortcut>
|
||||
<winMenu>false</winMenu>
|
||||
<javaOptions>
|
||||
<javaOption>-Dlog4j.configurationFile=log4j2-windows.yaml</javaOption>
|
||||
</javaOptions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>windows</id>
|
||||
<configuration>
|
||||
<resourceDir>${project.basedir}/src/main/resources/</resourceDir>
|
||||
<type>EXE</type>
|
||||
<winConsole>true</winConsole>
|
||||
<winShortcut>false</winShortcut>
|
||||
<winMenu>false</winMenu>
|
||||
<javaOptions>
|
||||
<javaOption>-Dlog4j.configurationFile=log4j2-installed.yaml</javaOption>
|
||||
</javaOptions>
|
||||
</configuration>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jpackage</goal>
|
||||
@@ -97,25 +147,71 @@
|
||||
<profile>
|
||||
<id>linux</id>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>log4j2-debian.yaml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.panteleyev</groupId>
|
||||
<artifactId>jpackage-maven-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>linux-deb</id>
|
||||
<configuration>
|
||||
<type>DEB</type>
|
||||
<installDir>/usr/local/bin</installDir>
|
||||
<linuxShortcut>false</linuxShortcut>
|
||||
<linuxPackageName>mkvasc</linuxPackageName>
|
||||
<linuxDebMaintainer>your@email.com</linuxDebMaintainer>
|
||||
</configuration>
|
||||
<id>filter-linux-package-info</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jpackage</goal>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/debian-package-info</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/deb</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>jdeb</artifactId>
|
||||
<groupId>org.vafer</groupId>
|
||||
<version>1.13</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jdeb</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<dataSet>
|
||||
<!-- JAR file -->
|
||||
<data>
|
||||
<src>${project.build.directory}/${project.build.finalName}.jar</src>
|
||||
<type>file</type>
|
||||
<mapper>
|
||||
<type>perm</type>
|
||||
<prefix>/usr/lib/${project.artifactId}</prefix>
|
||||
</mapper>
|
||||
</data>
|
||||
<!-- Launcher script -->
|
||||
<data>
|
||||
<src>${project.build.directory}/debian-package-info/bin/mkvaudiosubtitlechanger</src>
|
||||
<type>file</type>
|
||||
<mapper>
|
||||
<type>perm</type>
|
||||
<prefix>/usr/bin</prefix>
|
||||
<filemode>755</filemode>
|
||||
</mapper>
|
||||
</data>
|
||||
</dataSet>
|
||||
<controlDir>${project.build.directory}/debian-package-info/control</controlDir>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
@@ -197,8 +293,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
<source>${java-version}</source>
|
||||
<target>${java-version}</target>
|
||||
<compilerArgs>
|
||||
<arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
|
||||
</compilerArgs>
|
||||
@@ -218,51 +314,6 @@
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-jpackage-input</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/jpackage-input</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<includes>
|
||||
<include>${project.artifactId}-${project.version}.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.panteleyev</groupId>
|
||||
<artifactId>jpackage-maven-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<configuration>
|
||||
<name>${project.artifactId}</name>
|
||||
<vendor>RatzzFatzz</vendor>
|
||||
<appVersion>${project.version}</appVersion>
|
||||
|
||||
<destination>target/installer</destination>
|
||||
|
||||
<input>target/jpackage-input</input>
|
||||
<mainClass>at.pcgamingfreaks.mkvaudiosubtitlechanger.Main</mainClass>
|
||||
<mainJar>${project.artifactId}-${project.version}.jar</mainJar>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
|
||||
1
src/deb/bin/mkvaudiosubtitlechanger
Normal file
1
src/deb/bin/mkvaudiosubtitlechanger
Normal file
@@ -0,0 +1 @@
|
||||
java -Dlog4j.configurationFile=log4j2-debian.yaml -jar /usr/lib/${project.artifactId}/${project.artifactId}-${project.version}.jar "$@"
|
||||
8
src/deb/control/control
Normal file
8
src/deb/control/control
Normal file
@@ -0,0 +1,8 @@
|
||||
Package: ${project.artifactId}
|
||||
Version: ${project.version}
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
Depends: java-runtime (>=${java-version}), mkvtoolnix
|
||||
Maintainer: ${project.maintainer} <${project.maintainer.mail}>
|
||||
Description: ${project.description}
|
||||
@@ -12,6 +12,8 @@ import jakarta.validation.Validation;
|
||||
import jakarta.validation.Validator;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.core.config.Configurator;
|
||||
import picocli.CommandLine;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -39,6 +41,9 @@ public class Main implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (config.isDebug()) {
|
||||
Configurator.setRootLevel(Level.DEBUG);
|
||||
}
|
||||
validate();
|
||||
Config.setInstance(config);
|
||||
AttributeUpdaterKernel kernel = Config.getInstance().getCoherent() != null
|
||||
@@ -61,6 +66,9 @@ public class Main implements Runnable {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 0) {
|
||||
args = new String[] { "--help" };
|
||||
}
|
||||
new CommandLine(Main.class).execute(args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ public class Config {
|
||||
description = "Keywords to prefer specific subtitle tracks (Defaults will be overwritten; Default: ${DEFAULT-VALUE})")
|
||||
private Set<String> preferredSubtitles;
|
||||
|
||||
@CommandLine.Option(names = {"--debug"}, description = "Enable debug logging")
|
||||
private boolean debug;
|
||||
|
||||
@CommandLine.Option(names = {"-l", "--library"}, required = true, description = "path to library")
|
||||
public void setLibraryPath(File libraryPath) {
|
||||
if (!libraryPath.exists()) throw new CommandLine.ParameterException(spec.commandLine(), "Path does not exist: " + libraryPath.getAbsolutePath());
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DateValidator extends ConfigValidator<Date> {
|
||||
YAML yaml = new YAML(lastExecutionFile);
|
||||
return parse(yaml.getString(Config.getInstance().getNormalizedLibraryPath(), DateUtils.convert(DEFAULT_DATE)));
|
||||
} catch (YamlInvalidContentException | IOException e) {
|
||||
log.error("Couldn't open last-execution.properties");
|
||||
log.error("Couldn't open last-execution.properties", e);
|
||||
return INVALID_DATE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class FileFilter {
|
||||
BasicFileAttributes attributes = Files.readAttributes(pathName.toPath(), BasicFileAttributes.class);
|
||||
return isNewer(DateUtils.convert(attributes.creationTime().toMillis()));
|
||||
} catch (IOException e) {
|
||||
log.warn("File attributes could not be read.", e);
|
||||
log.warn("File attributes could not be read", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ public class MkvFileProcessor implements FileProcessor {
|
||||
private static final SubtitleTrackComparator subtitleTrackComparator =
|
||||
new SubtitleTrackComparator(Config.getInstance().getPreferredSubtitles().toArray(new String[0]));
|
||||
|
||||
private static final String DISABLE_DEFAULT_TRACK = "--edit track:%s --set flag-default=0 ";
|
||||
private static final String ENABLE_DEFAULT_TRACK = "--edit track:%s --set flag-default=1 ";
|
||||
private static final String DISABLE_FORCED_TRACK = "--edit track:%s --set flag-forced=0 ";
|
||||
private static final String ENABLE_FORCED_TRACK = "--edit track:%s --set flag-forced=1 ";
|
||||
private static final String DISABLE_DEFAULT_TRACK = "--edit track:%s --set flag-default=0";
|
||||
private static final String ENABLE_DEFAULT_TRACK = "--edit track:%s --set flag-default=1";
|
||||
private static final String DISABLE_FORCED_TRACK = "--edit track:%s --set flag-forced=0";
|
||||
private static final String ENABLE_FORCED_TRACK = "--edit track:%s --set flag-forced=1";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@@ -39,16 +39,17 @@ public class MkvFileProcessor implements FileProcessor {
|
||||
Map<String, Object> jsonMap;
|
||||
List<FileAttribute> fileAttributes = new ArrayList<>();
|
||||
try {
|
||||
String command = format("\"%s\"", Config.getInstance().getPathFor(MkvToolNix.MKV_MERGE));
|
||||
String[] arguments = new String[]{
|
||||
command,
|
||||
String[] command = new String[]{
|
||||
Config.getInstance().getPathFor(MkvToolNix.MKV_MERGE),
|
||||
"--identify",
|
||||
"--identification-format",
|
||||
"json",
|
||||
file.getAbsoluteFile().toString()
|
||||
file.getAbsolutePath()
|
||||
};
|
||||
|
||||
InputStream inputStream = Runtime.getRuntime().exec(arguments).getInputStream();
|
||||
log.debug("Executing '{}': {}", file.getAbsolutePath(), String.join(" ", command));
|
||||
InputStream inputStream = Runtime.getRuntime().exec(command)
|
||||
.getInputStream();
|
||||
jsonMap = mapper.readValue(inputStream, Map.class);
|
||||
List<Map<String, Object>> tracks = (List<Map<String, Object>>) jsonMap.get("tracks");
|
||||
if (tracks == null) {
|
||||
@@ -68,7 +69,7 @@ public class MkvFileProcessor implements FileProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
log.debug(fileAttributes.toString());
|
||||
log.debug("File attributes of '{}': {}", file.getAbsolutePath(), fileAttributes.toString());
|
||||
} catch (IOException e) {
|
||||
log.error("File could not be found or loaded: ", e);
|
||||
System.out.println("File could not be found or loaded: " + file.getAbsolutePath());
|
||||
@@ -148,46 +149,50 @@ public class MkvFileProcessor implements FileProcessor {
|
||||
*/
|
||||
@Override
|
||||
public void update(File file, FileInfoDto fileInfo) throws IOException, MkvToolNixException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(format("\"%s\" ", Config.getInstance().getPathFor(MkvToolNix.MKV_PROP_EDIT)));
|
||||
sb.append(format("\"%s\" ", file.getAbsolutePath()));
|
||||
List<String> command = new ArrayList<>();
|
||||
command.add(Config.getInstance().getPathFor(MkvToolNix.MKV_PROP_EDIT));
|
||||
command.add(String.format(file.getAbsolutePath()));
|
||||
|
||||
if (fileInfo.isAudioDifferent()) {
|
||||
if (fileInfo.getExistingDefaultAudioLanes() != null && !fileInfo.getExistingDefaultAudioLanes().isEmpty()) {
|
||||
for (FileAttribute track: fileInfo.getExistingDefaultAudioLanes()) {
|
||||
sb.append(format(DISABLE_DEFAULT_TRACK, track.getId()));
|
||||
for (FileAttribute track : fileInfo.getExistingDefaultAudioLanes()) {
|
||||
command.addAll(format(DISABLE_DEFAULT_TRACK, track.getId()));
|
||||
}
|
||||
}
|
||||
sb.append(format(ENABLE_DEFAULT_TRACK, fileInfo.getDesiredDefaultAudioLane().getId()));
|
||||
command.addAll(format(ENABLE_DEFAULT_TRACK, fileInfo.getDesiredDefaultAudioLane().getId()));
|
||||
}
|
||||
|
||||
if (!fileInfo.getExistingForcedAudioLanes().isEmpty()) {
|
||||
for (FileAttribute track: fileInfo.getExistingForcedAudioLanes()) {
|
||||
sb.append(format(DISABLE_FORCED_TRACK, track.getId()));
|
||||
for (FileAttribute track : fileInfo.getExistingForcedAudioLanes()) {
|
||||
command.addAll(format(DISABLE_FORCED_TRACK, track.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (fileInfo.isSubtitleDifferent()) {
|
||||
if (fileInfo.getExistingDefaultSubtitleLanes() != null && !fileInfo.getExistingDefaultSubtitleLanes().isEmpty()) {
|
||||
for (FileAttribute track: fileInfo.getExistingDefaultSubtitleLanes()) {
|
||||
sb.append(format(DISABLE_DEFAULT_TRACK, track.getId()));
|
||||
for (FileAttribute track : fileInfo.getExistingDefaultSubtitleLanes()) {
|
||||
command.addAll(format(DISABLE_DEFAULT_TRACK, track.getId()));
|
||||
}
|
||||
}
|
||||
if (fileInfo.getDesiredDefaultSubtitleLane() != null) {
|
||||
sb.append(format(ENABLE_DEFAULT_TRACK, fileInfo.getDesiredDefaultSubtitleLane().getId()));
|
||||
command.addAll(format(ENABLE_DEFAULT_TRACK, fileInfo.getDesiredDefaultSubtitleLane().getId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (fileInfo.areForcedTracksDifferent()) {
|
||||
for (FileAttribute attribute : fileInfo.getDesiredForcedSubtitleLanes()) {
|
||||
sb.append(format(ENABLE_FORCED_TRACK, attribute.getId()));
|
||||
for (FileAttribute track : fileInfo.getDesiredForcedSubtitleLanes()) {
|
||||
command.addAll(format(ENABLE_FORCED_TRACK, track.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
log.info(sb.toString());
|
||||
InputStream inputstream = Runtime.getRuntime().exec(sb.toString()).getInputStream();
|
||||
log.debug("Executing '{}'", String.join(" ", command));
|
||||
InputStream inputstream = Runtime.getRuntime().exec(command.toArray(new String[0])).getInputStream();
|
||||
String output = IOUtils.toString(new InputStreamReader(inputstream));
|
||||
log.debug(output);
|
||||
log.debug("Result: {}", output);
|
||||
if (output.contains("Error")) throw new MkvToolNixException(output);
|
||||
}
|
||||
|
||||
private List<String> format(String format, Object... args) {
|
||||
return Arrays.asList(String.format(format, args).split(" "));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import me.tongfei.progressbar.ProgressBar;
|
||||
import me.tongfei.progressbar.ProgressBarBuilder;
|
||||
import me.tongfei.progressbar.ProgressBarStyle;
|
||||
import net.harawata.appdirs.AppDirsFactory;
|
||||
import picocli.CommandLine;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -100,6 +99,12 @@ public abstract class AttributeUpdaterKernel {
|
||||
FileInfoDto fileInfo = new FileInfoDto(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> nonCommentaryTracks = processor.retrieveNonCommentaryTracks(attributes);
|
||||
|
||||
@@ -122,7 +127,7 @@ public abstract class AttributeUpdaterKernel {
|
||||
statistic.shouldChange();
|
||||
commitChange(fileInfoDto);
|
||||
break;
|
||||
case UNABLE_TO_APPLY:
|
||||
case NO_SUITABLE_CONFIG:
|
||||
statistic.noSuitableConfigFound();
|
||||
break;
|
||||
case ALREADY_SUITED:
|
||||
@@ -143,10 +148,10 @@ public abstract class AttributeUpdaterKernel {
|
||||
try {
|
||||
processor.update(fileInfo.getFile(), fileInfo);
|
||||
statistic.success();
|
||||
log.info("Updated {}", fileInfo.getFile().getAbsolutePath());
|
||||
log.info("Commited {} to '{}'", fileInfo.getMatchedConfig().toStringShort(), fileInfo.getFile().getAbsolutePath());
|
||||
} catch (IOException | MkvToolNixException e) {
|
||||
statistic.failedChanging();
|
||||
log.warn("File couldn't be updated: '{}', Error: {}", fileInfo.getFile().getAbsoluteFile(), e.getMessage());
|
||||
log.warn("Couldn't commit {} to '{}'", fileInfo.getMatchedConfig().toStringShort(), fileInfo.getFile().getAbsoluteFile(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class CoherentAttributeUpdaterKernel extends AttributeUpdaterKernel {
|
||||
|
||||
if (fileInfos.stream().allMatch(elem -> ("OFF".equals(config.getSubtitleLanguage()) || elem.getDesiredDefaultSubtitleLane() != null)
|
||||
&& elem.getDesiredDefaultAudioLane() != null)) {
|
||||
log.info("Found {}/{} match for {}", config.getAudioLanguage(), config.getSubtitleLanguage(), file.getAbsolutePath());
|
||||
log.info("Found {} match for {}", config.toStringShort(), file.getAbsolutePath());
|
||||
fileInfos.forEach(this::updateFile);
|
||||
return; // match found, end process here
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ public class AttributeConfig {
|
||||
return Objects.hash(audioLanguage, subtitleLanguage);
|
||||
}
|
||||
|
||||
public String toStringShort() {
|
||||
return audioLanguage + ":" + subtitleLanguage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AttributeConfig{"
|
||||
|
||||
@@ -40,8 +40,9 @@ public class FileInfoDto {
|
||||
}
|
||||
|
||||
private boolean isSubtitleOFF() {
|
||||
return desiredDefaultSubtitleLane == null && "OFF".equals(matchedConfig.getSubtitleLanguage()) &&
|
||||
(existingDefaultSubtitleLanes != null && !existingDefaultSubtitleLanes.isEmpty());
|
||||
return desiredDefaultSubtitleLane == null
|
||||
&& (matchedConfig != null && "OFF".equals(matchedConfig.getSubtitleLanguage()))
|
||||
&& (existingDefaultSubtitleLanes != null && !existingDefaultSubtitleLanes.isEmpty());
|
||||
}
|
||||
|
||||
public boolean areForcedTracksDifferent() {
|
||||
@@ -50,7 +51,7 @@ public class FileInfoDto {
|
||||
|
||||
public FileStatus getStatus() {
|
||||
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;
|
||||
return FileStatus.UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.model;
|
||||
|
||||
public enum FileStatus {
|
||||
CHANGE_NECESSARY,
|
||||
UNABLE_TO_APPLY,
|
||||
NO_SUITABLE_CONFIG,
|
||||
ALREADY_SUITED,
|
||||
UNKNOWN;
|
||||
}
|
||||
|
||||
34
src/main/resources/log4j2-debian.yaml
Normal file
34
src/main/resources/log4j2-debian.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
Configuration:
|
||||
name: DefaultLogger
|
||||
Appenders:
|
||||
RollingFile:
|
||||
name: FileAppender
|
||||
fileName: ${sys:user.home}/.local/mkvaudiosubtitlechanger/logs/application.log
|
||||
filePattern: ${sys:user.home}/.local/mkvaudiosubtitlechanger/logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz
|
||||
PatternLayout:
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable"
|
||||
ThresholdFilter:
|
||||
level: debug
|
||||
Policies:
|
||||
OnStartupTriggeringPolicy:
|
||||
minSize: 0
|
||||
DefaultRolloverStrategy:
|
||||
max: 30
|
||||
Delete:
|
||||
basePath: archive
|
||||
maxDepth: 1
|
||||
IfLastModified:
|
||||
age: 30d
|
||||
IfAccumulatedFileSize:
|
||||
exceeds: 1GB
|
||||
|
||||
Loggers:
|
||||
Root:
|
||||
level: info
|
||||
AppenderRef:
|
||||
- ref: FileAppender
|
||||
Logger:
|
||||
name: "com.zaxxer.hikari.HikariConfig"
|
||||
level: info
|
||||
AppenderRef:
|
||||
- ref: FileAppender
|
||||
@@ -4,20 +4,30 @@ Configuration:
|
||||
Console:
|
||||
name: Console_Out
|
||||
PatternLayout:
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %msg %n %throwable"
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable"
|
||||
ThresholdFilter:
|
||||
level: debug
|
||||
RollingFile:
|
||||
name: FileAppender
|
||||
fileName: logs/application.log
|
||||
filePattern: logs/archive/application-%d{yyyy-MM-dd}-%i.log
|
||||
filePattern: logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz
|
||||
PatternLayout:
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %msg %n %throwable"
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable"
|
||||
ThresholdFilter:
|
||||
level: debug
|
||||
Policies:
|
||||
OnStartupTriggeringPolicy:
|
||||
minSize: 0
|
||||
DefaultRolloverStrategy:
|
||||
max: 30
|
||||
Delete:
|
||||
basePath: logs/archive
|
||||
maxDepth: 1
|
||||
IfLastModified:
|
||||
age: 30d
|
||||
IfAccumulatedFileSize:
|
||||
exceeds: 1GB
|
||||
|
||||
Loggers:
|
||||
Root:
|
||||
level: debug
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
Configuration:
|
||||
name: DefaultLogger
|
||||
Appenders:
|
||||
File:
|
||||
name: FileAppender
|
||||
fileName: ${sys:user.home}/AppData/Roaming/MyApplication/MyApplication.log
|
||||
PatternLayout:
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %msg %n %throwable"
|
||||
ThresholdFilter:
|
||||
level: info
|
||||
RollingFile:
|
||||
name: FileAppender
|
||||
fileName: ${sys:user.home}/AppData/Roaming/MKVAudioSubtitleChanger/logs/application.log
|
||||
filePattern: ${sys:user.home}/AppData/Roaming/MKVAudioSubtitleChanger/logs/archive/application-%d{yyyy-MM-dd}-%i.log
|
||||
filePattern: ${sys:user.home}/AppData/Roaming/MKVAudioSubtitleChanger/logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz
|
||||
PatternLayout:
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %msg %n %throwable"
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable"
|
||||
ThresholdFilter:
|
||||
level: info
|
||||
level: debug
|
||||
Policies:
|
||||
OnStartupTriggeringPolicy:
|
||||
minSize: 0
|
||||
DefaultRolloverStrategy:
|
||||
max: 30
|
||||
Delete:
|
||||
basePath: logs/archive
|
||||
maxDepth: 1
|
||||
IfLastModified:
|
||||
age: 30d
|
||||
IfAccumulatedFileSize:
|
||||
exceeds: 1GB
|
||||
|
||||
Loggers:
|
||||
Root:
|
||||
level: info
|
||||
@@ -4,14 +4,24 @@ Configuration:
|
||||
RollingFile:
|
||||
name: FileAppender
|
||||
fileName: logs/application.log
|
||||
filePattern: logs/archive/application-%d{yyyy-MM-dd}-%i.log
|
||||
filePattern: logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz
|
||||
PatternLayout:
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %msg %n %throwable"
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable"
|
||||
ThresholdFilter:
|
||||
level: info
|
||||
level: debug
|
||||
Policies:
|
||||
OnStartupTriggeringPolicy:
|
||||
minSize: 0
|
||||
DefaultRolloverStrategy:
|
||||
max: 30
|
||||
Delete:
|
||||
basePath: logs/archive
|
||||
maxDepth: 1
|
||||
IfLastModified:
|
||||
age: 30d
|
||||
IfAccumulatedFileSize:
|
||||
exceeds: 1GB
|
||||
|
||||
Loggers:
|
||||
Root:
|
||||
level: info
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
<?endif?>
|
||||
|
||||
<?define JpProductCode="*"?>
|
||||
<?define JpAppName="MKVAudioSubtitleChanger"?>
|
||||
<?define JpAppVersion="4.0.0"?>
|
||||
<?define JpAppVendor="RatzzFatzz"?>
|
||||
<?define JpAppName="${project.artifactId}"?>
|
||||
<?define JpAppVersion="${project.version}"?>
|
||||
<?define JpAppVendor="${project.maintainer}"?>
|
||||
<?define JpProductUpgradeCode="a9527300-d364-4cc3-a392-94035065d8c9"?>
|
||||
<?define JpAppDescription="Change audio and subtitle tracks for .mkv files"?>
|
||||
<?define JpHelpURL="github.com/RatzzFatzz"?>
|
||||
<?define JpAppDescription="${project.description}"?>
|
||||
<?define JpHelpURL="github.com/${project.maintainer}/${project.artifactId}"?>
|
||||
|
||||
<Product
|
||||
Id="$(var.JpProductCode)"
|
||||
Reference in New Issue
Block a user