Added a check for the config file
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
3742c44c40
commit
ffb7d2d9f1
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user