我想通过编程方式从你脑中下载视频管。现在我能够流式传输这些你管视频。我在网上搜索..但是我没有完美的解决方案..请建议可能的解决方案对于这个问题。谢谢
答案 0 :(得分:3)
检查this。我使用此函数从youtube视频中提取直接下载链接(它返回带链接的数组)。您需要做的就是使用以下内容获取视频的html代码(而不是移动版!):
// url = youtube link (e.g. http://www.youtube.com/watch?v=fJ9rUzIMcZQ)
public String DownloadText(String url) throws IOException{
String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1)";
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, userAgent);
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
String html = "";
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null)
{
str.append(line);
}
in.close();
html = str.toString();
return html;
}