mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 10:05:58 +01:00
[IMPL] load multiple configs
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import config.MKVToolProperties;
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.AttributeUpdaterKernel;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@@ -6,8 +6,10 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
MKVToolProperties.getInstance().defineMKVToolNixPath();
|
// MKVToolProperties.getInstance().defineMKVToolNixPath();
|
||||||
GUI gui = new GUI();
|
// GUI gui = new GUI();
|
||||||
|
AttributeUpdaterKernel kernel = new AttributeUpdaterKernel();
|
||||||
|
kernel.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
package at.pcgamingfreaks.mkvaudiosubtitlechanger;
|
package at.pcgamingfreaks.mkvaudiosubtitlechanger;
|
||||||
|
|
||||||
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.config.AttributeConfig;
|
||||||
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.util.ConfigUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class AttributeUpdaterKernel {
|
public class AttributeUpdaterKernel {
|
||||||
|
public void execute() {
|
||||||
|
List<AttributeConfig> list = ConfigUtil.loadConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,16 @@
|
|||||||
package at.pcgamingfreaks.mkvaudiosubtitlechanger.config;
|
package at.pcgamingfreaks.mkvaudiosubtitlechanger.config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class AttributeConfig {
|
public class AttributeConfig {
|
||||||
|
private List<String> audio;
|
||||||
|
private List<String> subtitle;
|
||||||
|
|
||||||
|
public AttributeConfig(List<String> audio, List<String> subtitle) {
|
||||||
|
this.audio = audio;
|
||||||
|
this.subtitle = subtitle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package at.pcgamingfreaks.mkvaudiosubtitlechanger.util;
|
||||||
|
|
||||||
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.config.AttributeConfig;
|
||||||
|
import at.pcgamingfreaks.yaml.YAML;
|
||||||
|
import at.pcgamingfreaks.yaml.YamlInvalidContentException;
|
||||||
|
import at.pcgamingfreaks.yaml.YamlKeyNotFoundException;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
public class ConfigUtil {
|
||||||
|
public static List<AttributeConfig> loadConfig() {
|
||||||
|
try(YAML yaml = new YAML(new File("./src/main/resources/config.yaml"))){
|
||||||
|
return yaml.getKeysFiltered(".*audio.*").stream()
|
||||||
|
.sorted()
|
||||||
|
.map(elem -> elem.replace(".audio", ""))
|
||||||
|
.map(elem -> createAttributeConfig(elem, yaml))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}catch(YamlInvalidContentException | IOException e){
|
||||||
|
log.fatal("Config could not be loaded");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AttributeConfig createAttributeConfig(String key, YAML yaml) {
|
||||||
|
try{
|
||||||
|
return new AttributeConfig(
|
||||||
|
yaml.getStringList(key + ".audio"),
|
||||||
|
yaml.getStringList(key + ".subtitle"));
|
||||||
|
}catch(YamlKeyNotFoundException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package query;
|
package query;
|
||||||
|
|
||||||
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.FileAttribute;
|
||||||
import at.pcgamingfreaks.yaml.YAML;
|
import at.pcgamingfreaks.yaml.YAML;
|
||||||
import at.pcgamingfreaks.yaml.YamlInvalidContentException;
|
import at.pcgamingfreaks.yaml.YamlInvalidContentException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import config.MKVToolProperties;
|
import config.MKVToolProperties;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import model.FileAttribute;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
audio:
|
config:
|
||||||
|
1:
|
||||||
|
audio:
|
||||||
- jpn
|
- jpn
|
||||||
|
subtitle:
|
||||||
- ger
|
- ger
|
||||||
- eng
|
- eng
|
||||||
subtitle:
|
2:
|
||||||
- ger
|
audio:
|
||||||
|
- eng
|
||||||
|
- ger
|
||||||
|
subtitle:
|
||||||
- eng
|
- eng
|
||||||
Reference in New Issue
Block a user