Created
May 12, 2010 13:50
-
-
Save abhiomkar/398604 to your computer and use it in GitHub Desktop.
One-liner to download youtube video in Python
This file contains 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
# Author: Abhinay Omkar | |
# Title: One-liner to download youtube video in Python | |
from urllib import urlopen, unquote; from urlparse import parse_qs, urlparse; youtube_watchurl="http://www.youtube.com/watch?v=NeSuirvA6UE&playnext_from=TL&videos=MS3Hq4oBj08"; video_id = parse_qs(urlparse(youtube_watchurl).query)['v'][0]; open(video_id+'.mp4', 'wb').write(urlopen("http://www.youtube.com/get_video?video_id=%s&t=%s&fmt=18"%(video_id, parse_qs(unquote(urlopen('http://www.youtube.com/get_video_info?&video_id=' + video_id).read().decode('utf-8')))['token'][0])).read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'youtube-dl' works like a charm