Can't Download from youtube

前端 未结 4 644
臣服心动
臣服心动 2021-02-06 15:18

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*=&

相关标签:
4条回答
  • 2021-02-06 15:29

    Well it seems like they have removed the fmt option. See http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs.

    0 讨论(0)
  • 2021-02-06 15:32

    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.

    Deprecated: won't work anymore!

    0 讨论(0)
  • 2021-02-06 15:35

    I've created a node.js server that can stream YouTube videos directly to the client and it works. See https://github.com/licson0729/node-YouTubeStreamer for details.

    0 讨论(0)
  • 2021-02-06 15:42

    If you want to download to a server you can use youtube-dl which still works.

    0 讨论(0)
提交回复
热议问题