diff --git a/config.yaml b/config.yaml
index 37c82cc..9809263 100644
--- a/config.yaml
+++ b/config.yaml
@@ -1,3 +1,4 @@
+mkvtoolnixPath: /usr/bin
config:
1:
audio:
diff --git a/pom.xml b/pom.xml
index be5b0bc..e62cc98 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,6 +72,14 @@
maven-surefire-plugin
2.22.2
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 9
+ 9
+
+
diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/AttributeUpdaterKernel.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/AttributeUpdaterKernel.java
index fc29326..4a0e9e4 100644
--- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/AttributeUpdaterKernel.java
+++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/AttributeUpdaterKernel.java
@@ -18,18 +18,22 @@ public class AttributeUpdaterKernel {
public void execute(String path) {
List configPattern = ConfigUtil.loadConfig();
List allValidPaths = collector.loadFiles(path);
- if(! allValidPaths.isEmpty() && configPattern != null){
+ if(allValidPaths != null && configPattern != null){
for(File file : allValidPaths){
List attributes = collector.loadAttributes(file);
+ boolean fileHasChanged = false;
for(AttributeConfig config : configPattern){
/*
* Creating new ArrayList, because the method removes elements from the list by reference
*/
- boolean fileHasChanged = new ConfigProcessor(config).processConfig(file, new ArrayList<>(attributes));
+ fileHasChanged = new ConfigProcessor(config).processConfig(file, new ArrayList<>(attributes));
if(fileHasChanged){
break;
}
}
+ if(! fileHasChanged){
+ log.info(file.getName() + " didn't change!");
+ }
}
}else{
log.error("Path is not valid or config has errors!");
diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/Main.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/Main.java
index 06ad776..ea645a3 100644
--- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/Main.java
+++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/Main.java
@@ -21,12 +21,17 @@ public class Main {
private static boolean checkIfMKVToolNixIsValid() {
try{
- String path = new YAML(new File("config.yml")).getString("mkvtoolnixPath");
+ String path = new YAML(new File("config.yaml")).getString("mkvtoolnixPath");
if(! path.endsWith(File.separator)){
path += File.separator;
}
- MKVToolProperties.getInstance().setMkvmergePath(path + "mkvmerge");
- MKVToolProperties.getInstance().setMkvpropeditPath(path + "mkvproperties");
+ if(System.getProperty("os.name").toLowerCase().contains("windows")){
+ MKVToolProperties.getInstance().setMkvmergePath(path + "mkvmerge.exe");
+ MKVToolProperties.getInstance().setMkvpropeditPath(path + "mkvpropedit.exe");
+ }else{
+ MKVToolProperties.getInstance().setMkvmergePath(path + "mkvmerge");
+ MKVToolProperties.getInstance().setMkvpropeditPath(path + "mkvpropedit");
+ }
}catch(YamlKeyNotFoundException | IOException | YamlInvalidContentException e){
e.printStackTrace();
}
diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/config/ConfigProcessor.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/config/ConfigProcessor.java
index 9efd6e6..9e226bc 100644
--- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/config/ConfigProcessor.java
+++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/config/ConfigProcessor.java
@@ -84,9 +84,15 @@ public class ConfigProcessor {
* @return if the the current file was updated or not. Returns true if the file already has the correct metadata set
*/
private boolean updateFile(File file, List attributes, TransferObject transfer) {
- StringBuilder stringBuffer = new StringBuilder("\"");
- stringBuffer.append(MKVToolProperties.getInstance().getMkvpropeditPath());
- stringBuffer.append("\" \"").append(file.getAbsolutePath()).append("\" ");
+ StringBuilder stringBuffer = new StringBuilder();
+ if(System.getProperty("os.name").toLowerCase().contains("windows")){
+ stringBuffer.append("\"");
+ stringBuffer.append(MKVToolProperties.getInstance().getMkvpropeditPath());
+ stringBuffer.append("\" \"").append(file.getAbsolutePath()).append("\" ");
+ }else{
+ stringBuffer.append(MKVToolProperties.getInstance().getMkvpropeditPath());
+ stringBuffer.append(" ").append(file.getAbsolutePath()).append(" ");
+ }
if(audioDefault != - 1){
stringBuffer.append("--edit track:=").append(audioDefault).append(" --set flag-default=0 ");
}
@@ -106,18 +112,19 @@ public class ConfigProcessor {
* In this case the file would be change to the exact same audio and subtitle lines and we want to
* avoid unnecessary changes to the file
*/
+ log.info(file.getName() + " already fits config!");
return true;
}
try{
Runtime.getRuntime().exec(stringBuffer.toString());
}catch(IOException e){
log.error("Couldn't make changes to file");
-
}
/*
* We return true even if there was an error. If there was an error, the chances that this file is still
* busy later.
*/
+ log.info(file.getName() + " was updated");
return true;
}else{
return false;
diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/intimpl/MkvFileCollector.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/intimpl/MkvFileCollector.java
index 3b43e44..8e56e10 100644
--- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/intimpl/MkvFileCollector.java
+++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/intimpl/MkvFileCollector.java
@@ -56,14 +56,24 @@ public class MkvFileCollector implements FileCollector {
public List loadAttributes(File file) {
Map jsonMap;
List fileAttributes = new ArrayList<>();
- System.out.println("\"" + MKVToolProperties.getInstance().getMkvmergePath()
- + "\" --identify --identification-format json \"" + file.getAbsolutePath() + "\"");
- try(InputStream inputStream =
- Runtime.getRuntime().exec("\"" + MKVToolProperties.getInstance().getMkvmergePath()
- + "\" --identify --identification-format json \"" + file.getAbsolutePath() + "\"").getInputStream()){
+ try{
+ String command = "";
+ if(System.getProperty("os.name").toLowerCase().contains("windows")){
+ command = "\"" + MKVToolProperties.getInstance().getMkvmergePath() + "\"";
+ }else{
+ command = MKVToolProperties.getInstance().getMkvmergePath();
+ }
+ String[] array = new String[]{
+ command,
+ "--identify",
+ "--identification-format",
+ "json",
+ file.getAbsoluteFile().toString()
+ };
+
+ InputStream inputStream = Runtime.getRuntime().exec(array).getInputStream();
jsonMap = mapper.readValue(inputStream, Map.class);
List