From 3695e4bb1300a0207663b08a88a566a2de10f46c Mon Sep 17 00:00:00 2001 From: Nekojimi Date: Wed, 29 Sep 2021 20:08:36 +0100 Subject: [PATCH] Downloader: try to get low-quality audio for now. --- src/main/java/moe/nekojimi/chords/Downloader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/moe/nekojimi/chords/Downloader.java b/src/main/java/moe/nekojimi/chords/Downloader.java index ca8408a..78b8e69 100644 --- a/src/main/java/moe/nekojimi/chords/Downloader.java +++ b/src/main/java/moe/nekojimi/chords/Downloader.java @@ -55,7 +55,7 @@ public class Downloader implements Consumer try { 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); // Process exec = Runtime.getRuntime().exec().split(" ")); Process exec = new ProcessBuilder(cmd.split(" ")).redirectOutput(ProcessBuilder.Redirect.PIPE).start(); @@ -68,7 +68,7 @@ public class Downloader implements Consumer InputStream in = exec.getInputStream(); String output = new String(in.readAllBytes(), Charset.defaultCharset()); System.out.println(output); - Matcher matcher = Pattern.compile("Destination: (.*\\.wav)").matcher(output); + Matcher matcher = Pattern.compile("Destination: (.*)$").matcher(output); if (matcher.find()) song.setLocation(new File(matcher.group(1))); else if (exec.exitValue() != 0)