Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
One-liner to download youtube video in Python
# 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())
@skeggse

This comment has been minimized.

Show comment
Hide comment
@skeggse

skeggse Jul 30, 2012

At the moment, this does not work.

skeggse commented Jul 30, 2012

At the moment, this does not work.

@aadisriram

This comment has been minimized.

Show comment
Hide comment
@aadisriram

aadisriram Sep 20, 2012

So we have a problem now, most videos cannot be downloaded as they have been protected by uploader to disallow playback on external sites

So we have a problem now, most videos cannot be downloaded as they have been protected by uploader to disallow playback on external sites

@tejasbubane

This comment has been minimized.

Show comment
Hide comment
@tejasbubane

tejasbubane Sep 28, 2012

'youtube-dl' works like a charm

'youtube-dl' works like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment