diff --git a/src/main/java/tech/bitgoblin/App.java b/src/main/java/tech/bitgoblin/App.java index b0eb866..0bcb610 100644 --- a/src/main/java/tech/bitgoblin/App.java +++ b/src/main/java/tech/bitgoblin/App.java @@ -9,9 +9,11 @@ import tech.bitgoblin.video.Transcoder; */ public class App { + private static final String configFile = "~/.config/dragoon.toml"; + public static void main(String[] args) { // read our config file - Config c = new Config("~/dragoon/config.toml"); + Config c = new Config(configFile); // create new Transcoder object and start the service //Transcoder t = new Transcoder("~/dragoon"); //t.transcode(); diff --git a/src/main/java/tech/bitgoblin/config/Config.java b/src/main/java/tech/bitgoblin/config/Config.java index 4c30551..f6efc2a 100644 --- a/src/main/java/tech/bitgoblin/config/Config.java +++ b/src/main/java/tech/bitgoblin/config/Config.java @@ -1,5 +1,6 @@ package tech.bitgoblin.config; +import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; @@ -17,13 +18,18 @@ public class Config { // parse config file try { this.parseConfig(); - String value = result.getString("repo"); + String value = this.result.getString("repo"); System.out.println(value); } catch (IOException e) { - throw new RuntimeException(e); + System.out.println("Unable to read config file; please check that " + this.configPath + " is available."); + System.exit(1); } } + public String getString(String key) { + return this.result.getString(key); + } + private void parseConfig() throws IOException { // parse config file Path source = Paths.get(this.configPath); diff --git a/src/main/java/tech/bitgoblin/video/Transcoder.java b/src/main/java/tech/bitgoblin/video/Transcoder.java index 5d89e02..a02968b 100644 --- a/src/main/java/tech/bitgoblin/video/Transcoder.java +++ b/src/main/java/tech/bitgoblin/video/Transcoder.java @@ -12,16 +12,19 @@ import java.nio.file.Paths; import java.util.function.Consumer; import java.util.concurrent.Executors; +import tech.bitgoblin.config.Config; import tech.bitgoblin.io.IOUtils; public class Transcoder { private String repo_dir; + private Config config; private String ffmpeg_path = "/usr/bin/ffmpeg"; // only define the working directory; use default FFMPEG path - public Transcoder(String repo_dir) { - this.repo_dir = IOUtils.resolveTilda(repo_dir); + public Transcoder(Config config) { + this.config = config; + this.repo_dir = IOUtils.resolveTilda(config.getString("transcoder.repo_path")); this.initDirectory(); } // define a custom FFMPEG binary path