无法从YouTube下载 [英] Can't Download from youtube

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

问题描述

我有一个脚本从YouTube下载mp4文件。它的作用是生成 http://youtube.com/get_video?video_id= 形式的链接* VIDEO_ID *&& t = * THE_TOKEN * =& fmt = 18& asv = 2,但不再工作(今天注意到)。你怎么看?

解决方案

不要尝试使用get_video来获取视频,请尝试解析fmt_url_map(format-url map)



您应该可以在找到令牌的同一个地方找到fmt_url_map(如在YouTube Flash视频播放器的Flashvars或YouTube页面的某个地方) )。如果您找不到,请发送 http://www.youtube.com/get_video_info?的请求? video_id = VIDEO_ID ,您应该获得一个非常长的结果,格式为 name = value& name = value& ... 在此结果中查找fmt_url_map(搜索结果为& fmt_url_map =开头的字符串,并以&结尾)。



获得此值后(您可能需要使用url解码),它将像(没有换行符):

  22 | http://blah.youtube.com/videoplayback?blah,
35 | http://blah.youtube.com/videoplayback?blah,
...

其中每个逗号分隔的条目以fmt值开头(示例中为22或35),后跟一个管道字符,然后是URL,您可以使用该URL下载该格式的视频。 (该URL是特定于客户端的,因此,由于YouTube检查IP,因此特定客户端的URL很可能不会与另一个客户端一起使用。此外,URL会在一段时间后到期。)



有关不同fmt值的列表,请参阅: http:// en。 wikipedia.org/wiki/YouTube#Quality_and_formats ,并显示YouTube媒体编码选项的比较。注意:并非所有格式的所有视频都可用。


I have a script that downloads mp4 files from youtube. What it does is to generate link of the form http://youtube.com/get_video?video_id=*VIDEO_ID*&&t=*THE_TOKEN*=&fmt=18&asv=2, but it doesn't work anymore (noticed it today). What do you think?

解决方案

Instead of trying to use get_video to get the video, try parsing fmt_url_map (format-url map) instead.

You should be able to find the fmt_url_map in the same place you found the token (like in the flashvars of the YouTube flash video player or inside the YouTube page somewhere). If you can't find it, send a request to http://www.youtube.com/get_video_info?video_id=VIDEO_ID and you should get a really long result that is in the format of name=value&name=value&... Find "fmt_url_map" inside this result (search through the result for a string that starts with "&fmt_url_map=" and ends with "&").

After you get this value (you may have to url-decode it), it will be something like (without the line breaks):

22|http://blah.youtube.com/videoplayback?blah,
35|http://blah.youtube.com/videoplayback?blah,
...

where each comma-separated entry starts with the fmt value (22 or 35 in the example), followed by a pipe character, which is then followed by the URL where you can use to download the video in that format. (This URL is client-specific, so a URL for a certain client most likely won't work with another client due to YouTube checking IPs. Also, the URLs do expire after a while.)

For a list of the different fmt values, see: http://en.wikipedia.org/wiki/YouTube#Quality_and_formats and show the "Comarison of YouTube media encoding options". NOTE: not all formats may be available for all videos.

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

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