Downloader: try to get low-quality audio for now.

crossfading
Nekojimi 3 years ago
parent c8810ca271
commit 3695e4bb13
  1. 4
      src/main/java/moe/nekojimi/chords/Downloader.java

@ -55,7 +55,7 @@ public class Downloader implements Consumer<Song>
try try
{ {
messageHandler.accept(song, null); messageHandler.accept(song, null);
String cmd = "/usr/bin/youtube-dl -x --audio-format=wav --no-playlist --write-info-json " + song.getUrl().toString(); String cmd = "/usr/bin/youtube-dl -x -f=worstaudio/worst --audio-format=wav --no-playlist --write-info-json " + song.getUrl().toString();
System.out.println("Running command: " + cmd); System.out.println("Running command: " + cmd);
// Process exec = Runtime.getRuntime().exec().split(" ")); // Process exec = Runtime.getRuntime().exec().split(" "));
Process exec = new ProcessBuilder(cmd.split(" ")).redirectOutput(ProcessBuilder.Redirect.PIPE).start(); Process exec = new ProcessBuilder(cmd.split(" ")).redirectOutput(ProcessBuilder.Redirect.PIPE).start();
@ -68,7 +68,7 @@ public class Downloader implements Consumer<Song>
InputStream in = exec.getInputStream(); InputStream in = exec.getInputStream();
String output = new String(in.readAllBytes(), Charset.defaultCharset()); String output = new String(in.readAllBytes(), Charset.defaultCharset());
System.out.println(output); System.out.println(output);
Matcher matcher = Pattern.compile("Destination: (.*\\.wav)").matcher(output); Matcher matcher = Pattern.compile("Destination: (.*)$").matcher(output);
if (matcher.find()) if (matcher.find())
song.setLocation(new File(matcher.group(1))); song.setLocation(new File(matcher.group(1)));
else if (exec.exitValue() != 0) else if (exec.exitValue() != 0)

Loading…
Cancel
Save