Created
April 29, 2015 10:13
-
-
Save mba811/151d64a4808f40a4f48e to your computer and use it in GitHub Desktop.
ruby-youtube-downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'cgi' | |
| def video_token(video_id) | |
| token = CGI.parse(%x!curl http://www.youtube.com/get_video_info?video_id=#{video_id}!)['token'][0] | |
| end | |
| def video_id(url) | |
| CGI.parse(url.split('?')[1])['v'] | |
| end | |
| url = ARGV[0] | |
| download = "http://youtube.com/get_video?t=#{video_token(video_id(url))}&video_id=#{video_id(url)}&asv=2" | |
| %x!/usr/bin/env curl -L -C - -o test '#{download}'! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment