下载YouTube视频中的机器人 [英] Download youtube videos in android

查看:243
本文介绍了下载YouTube视频中的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android中通过programmatically..Still从你管下载视频现在我可以能够流这些你管videos.I在Internet..But搜索存在对me..Please没有完美的解决方案建议,可能的解决方案对于issue..Thanks

I want to download videos from you tube in android by programmatically..Still now i can able to stream these you tube videos.I searched in Internet..But there is no perfect solution for me..Please suggest that possible solutions for that issue..Thanks

推荐答案

检查<一href="http://stackoverflow.com/questions/13537202/play-high-quality-youtube-videos-using-videoview#comment19679509_13537202">this出。我用这个函数来提取从YouTube视频的直接下载链接(它返回一个链接数组)。所有你需要做的就是用这个来获取视频(而不是手机版!)的HTML code:

Check this out. I use this function to extract the direct download links from a youtube video (it returns an array with links). All you need to do is to get the html code of the video (not the mobile version!) using this:

                 // 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;
    }

这篇关于下载YouTube视频中的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆