开发者

Download YouTube with Ruby (sourcecode)

I wish to download a video from YouTube and then extract its audio. Can anyone point me to some Ruby code to download a vi开发者_高级运维deo? Thanks!


gem install curltube

then run curltube <youtube-url>

https://github.com/maxogden/curltube


Not sure how you would extract audio, but Ruby has many good scraping/mining libraries. You can use these to automate a browser and get scrape the data you need (e.g. the video embed code).

I recommend using a combination of mechanize and hpricot but here's a fairly comprehensive list:

Hpricot Mechanize Scrapi Scrubyt Nokogiri

You might also try Rio for downloading files/videos:

Rio: http://rio.rubyforge.org/

Hope it helps.


There's a more recent video downloader project here on github that allows you to grab flash video from different sites.


Check https://github.com/davidgaya/youtube_rb

Its tiny and uncomplete.

It can get your expiring and customized URI for a video stream.

@video = YoutubeVideo.new "http://www.youtube.com/watch?v=zzG4K2m_j5U"
@video.stream_uri

Once you have the stream_uri, you can download it, and process it using ffmpeg or gstreamer.


Here is some ruby code to download a youtube video. Unfortunely the library is written in python.

system("youtube-dl", "-o", filename, youtube_url)

You can extract the audio with the following

system("mplayer", "-dumpaudio", "-dumpfile", audo_filename, filename)


Here's a link to some Ruby source code that will download the FLV from youtube:

http://www.rorcraft.com/2008/08/29/download-youtube-videos-with-ruby/

I haven't tried it out myself, but it's worth a shot.


Also you and use quvi. It understands youtube and lots of other sites. Also it can handle playlists. I've posted code sample here https://stackoverflow.com/a/23127407/98509

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜