六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 50|回复: 0

Downloading YouTube Videos with a Groovy one-liner, and convert it to mpeg4

[复制链接]

升级  68%

8

主题

8

主题

8

主题

童生

Rank: 1

积分
34
 楼主| 发表于 2013-1-15 03:14:23 | 显示全部楼层 |阅读模式
Today I used LiveHTTPHeaders to take a closer look at how the youtube video streams are directed to the browser. And I found that my previous attempt actually has some redundency in it. To get the flv video stream, simply request the URL:
http://cache.googlevideo.com/get_video?video_id=${vid}where vid is simply the v string in the original URL. e.g. http://www.youtube.com/watch?v=5C0I7Ef4gQI
So the simplified version is one line of code even shorter now.
<div style=""><div style="">def vid = (args[0] =~ (/(?<=v=).*$/)).getAt(0)new File(“${vid}.flv”).withOutputStream{os -> new URL(“http://cache.googlevideo.com/get_video?video_id=${vid}”).openStream().eachByte{it -> os.write(it)}}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表