0
YouTube 비디오 &에서 오디오를 다운로드하려고 시도하면 작업 디렉토리에 a.mp3
으로 저장됩니다. 여기에 임 유튜브-DL 자바 래퍼를 사용하여 내가 좋아 : 내가 말할 수있는, 올바르게 설정에서, & 내가 작업 디렉토리를 제공 할 수 있지만 https://github.com/sapher/youtubedl-java이Java youtube-dl 해당 파일이나 디렉토리가 없습니다.
, 내가 점점 계속 :
Exception in thread "main" com.sapher.youtubedl.YoutubeDLException: Cannot run program "youtube-dl" (in directory "/Users/stephenogden/workspace/Gary"): error=2, No such file or directory
at com.sapher.youtubedl.YoutubeDL.execute(YoutubeDL.java:69)
at TestingFunctions.functionTotest(TestingFunctions.java:43)
at TestingFunctions.main(TestingFunctions.java:15)
대상 디렉토리를 이동하려고 시도했지만 문제가 계속 발생합니다.
import java.io.File;
import java.io.IOException;
import com.sapher.youtubedl.YoutubeDL;
import com.sapher.youtubedl.YoutubeDLException;
import com.sapher.youtubedl.YoutubeDLRequest;
import com.sapher.youtubedl.YoutubeDLResponse;
public class TestingFunctions {
public static void main(String[] args) throws InterruptedException, YoutubeDLException {
try {
functionTotest("https://www.youtube.com/watch?v=DECxluN8OZM");
} catch (IOException e) {
e.printStackTrace();
}
}
public static void functionTotest(String url) throws IOException, InterruptedException, YoutubeDLException {
File a = new File("a.mp3");
if (a.exists()) {
a.delete();
}
// This is the command to run
String videoUrl = url;
String directory = System.getProperty("user.dir");
YoutubeDLRequest request = new YoutubeDLRequest(videoUrl, directory);
request.setOption("no-mark-watched");
request.setOption("ignore-errors");
request.setOption("no-playlist");
request.setOption("extract-audio");
request.setOption("audio-format \"mp3\"");
request.setOption("output \"a.%(ext)s\"");
YoutubeDLResponse response = YoutubeDL.execute(request);
String stdOut = response.getOut();
System.out.println(stdOut);
System.out.println("File downloaded!");
}
}
가 먼저'유튜브 - dl'를 설치 했나요 :
나는 추가했다? 만약 그렇다면 -'$ PATH'에 int를 추가 했습니까? – fukanchik예 설치가 되었기 때문에'brew install youtube-dl'을 사용했습니다. – Spud