Created
July 30, 2012 13:21
-
-
Save vikki/3206868 to your computer and use it in GitHub Desktop.
YouTube HTML5 Video Proxy
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
ytVideoUrlMatcher = r'url_encoded_fmt_stream_map=url=([^&]*)&' | |
ytVideoInfoUrlBase = 'http://www.youtube.com/get_video_info?html5=1&video_id=' | |
def getHTML5VideoFileFromYouTube(videoId): | |
videoInfoUrl = ytVideoInfoUrlBase + videoId | |
videoInfoFile = urllib2.urlopen(videoInfoUrl) | |
videoInfo = urllib2.unquote(videoInfoFile.read()) | |
vidMatch = re.search(ytVideoUrlMatcher, videoInfo) | |
videoUrl = vidMatch.groups(0)[0] | |
videoUrl = urllib2.unquote(videoUrl) | |
return urllib2.urlopen(vidUrl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment