fix youtube download urls

This commit is contained in:
j 2012-11-01 13:14:59 +01:00
parent 0001859ba8
commit dd316160be

View file

@ -13,6 +13,8 @@ def video_url(youtubeId, format='mp4', timeout=cache_timeout):
youtubeId - if of video
format - video format, options: webm, 1080p, 720p, mp4, high
"""
def get_url(stream):
return '%s&signature=%s' % (stream['url'], stream['sig'])
fmt = None
if format == '1080p':
fmt=37
@ -24,11 +26,11 @@ def video_url(youtubeId, format='mp4', timeout=cache_timeout):
fmt=35
elif format == 'webm':
streams = videos(youtubeId, 'webm')
return streams[max(streams.keys())]['url']
return get_url(streams[max(streams.keys())])
streams = videos(youtubeId)
if str(fmt) in streams:
return streams[str(fmt)]['url']
return get_url(streams[str(fmt)])
def find(query, max_results=10, offset=1, orderBy='relevance'):
query = quote(query)