From 2412d57f4d9982a9c78a104140a07b8c2958625b Mon Sep 17 00:00:00 2001 From: Nekojimi Date: Wed, 29 Sep 2021 22:07:56 +0100 Subject: [PATCH] Downloader: change timeout to 300 seconds, and fix destination parsing. --- src/main/java/moe/nekojimi/chords/Downloader.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/moe/nekojimi/chords/Downloader.java b/src/main/java/moe/nekojimi/chords/Downloader.java index 78b8e69..cf1ad3d 100644 --- a/src/main/java/moe/nekojimi/chords/Downloader.java +++ b/src/main/java/moe/nekojimi/chords/Downloader.java @@ -6,7 +6,6 @@ package moe.nekojimi.chords; import java.io.File; -import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; import java.util.concurrent.LinkedBlockingDeque; @@ -59,7 +58,7 @@ public class Downloader implements Consumer System.out.println("Running command: " + cmd); // Process exec = Runtime.getRuntime().exec().split(" ")); Process exec = new ProcessBuilder(cmd.split(" ")).redirectOutput(ProcessBuilder.Redirect.PIPE).start(); - boolean done = exec.waitFor(30, TimeUnit.SECONDS); + boolean done = exec.waitFor(300, TimeUnit.SECONDS); if (!done) { exec.destroyForcibly(); @@ -68,7 +67,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: (.*)$").matcher(output); + Matcher matcher = Pattern.compile("Destination: (.*\\.wav)").matcher(output); if (matcher.find()) song.setLocation(new File(matcher.group(1))); else if (exec.exitValue() != 0)