有没有一个java API可以从youtube下载视频?
我知道 YouTube Java API 不提供从 YouTube 下载视频的功能。但是,有没有办法使用 Java 下载给定浏览器 url 的 YouTube 视频并将其保存到文件中?我正在寻找类似的东西:
URL videoURL = getVideoURL();
// videoURL is input from user, as in http://www.youtube.com/watch?v=dfjghdjogdjgh
YoutubeVideo videoDownload = new YoutubeVideo(videoURL);
OutputStream outStream = new BufferedOutputStream(new FileOutputStream(getOutFile()));
//getOutfile gets file provided by user
InputStream inStream = new BufferedInputStream(videoDownload.getInputStream());
byte[] buffer = new byte[4096];
int n;
while ((n = inStream.read(buffer)) != -1){
outStream.write(buffer, 0, n);
}
outStream.close();
inStream.close();
I know that the YouTube Java API doesn't provide functionality for downloading a video from youtube. However, is there any way to download a youtube video given the browser url with Java and save to a file? I'm looking for something along these lines:
URL videoURL = getVideoURL();
// videoURL is input from user, as in http://www.youtube.com/watch?v=dfjghdjogdjgh
YoutubeVideo videoDownload = new YoutubeVideo(videoURL);
OutputStream outStream = new BufferedOutputStream(new FileOutputStream(getOutFile()));
//getOutfile gets file provided by user
InputStream inStream = new BufferedInputStream(videoDownload.getInputStream());
byte[] buffer = new byte[4096];
int n;
while ((n = inStream.read(buffer)) != -1){
outStream.write(buffer, 0, n);
}
outStream.close();
inStream.close();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论