diff --git a/pom.xml b/pom.xml index 2250ae8..1644228 100644 --- a/pom.xml +++ b/pom.xml @@ -72,24 +72,6 @@ maven-surefire-plugin 2.22.2 - - org.codehaus.mojo - ideauidesigner-maven-plugin - 1.0-beta-1 - - - - javac2 - - - - - - true - true - true - - diff --git a/src/main/java/GUI.java b/src/main/java/GUI.java index d4b7c15..de27d21 100644 --- a/src/main/java/GUI.java +++ b/src/main/java/GUI.java @@ -1,10 +1,8 @@ -import config.CustomOutputStream; import lombok.extern.log4j.Log4j2; import model.FileAttribute; import query.QueryBuilder; import javax.swing.*; -import javax.swing.text.DefaultCaret; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -18,25 +16,15 @@ public class GUI { private String path; private JButton openFileBrowser; private JButton startOperation; - private JButton openProperties; - private JTextArea outputArea; public GUI() { JFrame frame = new JFrame(); frame.setLayout(new BorderLayout()); frame.setTitle("MKV Audio and Subtitle Changer"); - frame.setSize(500, 300); + frame.setSize(500, 75); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - JPanel top = new JPanel(new GridLayout(1, 3, 20, 20)); - - outputArea = new JTextArea(); - DefaultCaret caret = (DefaultCaret) outputArea.getCaret(); - caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); - PrintStream printStream = new PrintStream(new CustomOutputStream(outputArea)); - System.setOut(printStream); - System.setErr(printStream); - outputArea.setEditable(false); + JPanel top = new JPanel(new GridLayout(1, 2, 20, 20)); openFileBrowser = new JButton("Browse directory"); openFileBrowser.addActionListener(new ActionListener() { @@ -74,15 +62,12 @@ public class GUI { } }); - openProperties = new JButton("Open properties"); - openProperties.setEnabled(false); - startOperation = new JButton("Start updating"); startOperation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { QueryBuilder queryBuilder = new QueryBuilder(); - if(queryBuilder.executeUpdateOnAllFiles(path, outputArea)){ + if(queryBuilder.executeUpdateOnAllFiles(path)){ log.info("All files updated!"); System.out.println("All files updated!"); } @@ -92,10 +77,8 @@ public class GUI { top.add(openFileBrowser); top.add(startOperation); - top.add(openProperties); frame.add(top, BorderLayout.NORTH); - frame.add(outputArea); frame.setVisible(true); } diff --git a/src/main/java/query/QueryBuilder.java b/src/main/java/query/QueryBuilder.java index c10cea0..0bf5996 100644 --- a/src/main/java/query/QueryBuilder.java +++ b/src/main/java/query/QueryBuilder.java @@ -7,7 +7,6 @@ import config.MKVToolProperties; import lombok.extern.log4j.Log4j2; import model.FileAttribute; -import javax.swing.*; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -27,7 +26,7 @@ public class QueryBuilder { public QueryBuilder() { } - public boolean executeUpdateOnAllFiles(String path, JTextArea outputArea) { + public boolean executeUpdateOnAllFiles(String path) { List allFilePaths = getAllFilesFromDirectory(path); if(allFilePaths == null){ log.error("Couldn't process path!"); @@ -35,8 +34,6 @@ public class QueryBuilder { } for(String filePath : allFilePaths){ updateAttributes(filePath, queryAttributes(filePath)); - log.info("Success: " + filePath); - System.out.println("Success: " + filePath); } return true; } @@ -85,7 +82,7 @@ public class QueryBuilder { List audios = null; try{ - yaml = new YAML(new File("config.yaml")); + yaml = new YAML(new File("./src/main/resources/config.yaml")); subtitles = yaml.getStringList("subtitle", null); audios = yaml.getStringList("audio", null); @@ -129,6 +126,13 @@ public class QueryBuilder { oldSubtitleDefault = attribute.getId(); } } + if(oldAudioDefault == audioDefault && oldSubtitleDefault == subtitleDefault){ + return; + } + if(audioIndex != 0){ + subtitleDefault = oldSubtitleDefault; + } + StringBuilder stringBuffer = new StringBuilder("\""); stringBuffer.append(MKVToolProperties.getInstance().getMkvpropeditPath()); stringBuffer.append("\" \"").append(path).append("\" "); @@ -143,11 +147,13 @@ public class QueryBuilder { log.error("Couldn't make changes to file"); } + log.info("Success: " + path); }else{ log.info("There were not enough lines provided to make any changes to the file"); } }catch(YamlInvalidContentException | IOException e){ + log.error("Failure: " + path); log.error(e.getMessage()); } } diff --git a/src/main/resources/config.yaml b/src/main/resources/config.yaml index c709d2b..341f395 100644 --- a/src/main/resources/config.yaml +++ b/src/main/resources/config.yaml @@ -3,5 +3,5 @@ audio: - ger - eng subtitle: - - eng - - ger \ No newline at end of file + - ger + - eng \ No newline at end of file