fix youtube download urls
This commit is contained in:
parent
0001859ba8
commit
dd316160be
1 changed files with 4 additions and 2 deletions
|
@ -13,6 +13,8 @@ def video_url(youtubeId, format='mp4', timeout=cache_timeout):
|
||||||
youtubeId - if of video
|
youtubeId - if of video
|
||||||
format - video format, options: webm, 1080p, 720p, mp4, high
|
format - video format, options: webm, 1080p, 720p, mp4, high
|
||||||
"""
|
"""
|
||||||
|
def get_url(stream):
|
||||||
|
return '%s&signature=%s' % (stream['url'], stream['sig'])
|
||||||
fmt = None
|
fmt = None
|
||||||
if format == '1080p':
|
if format == '1080p':
|
||||||
fmt=37
|
fmt=37
|
||||||
|
@ -24,11 +26,11 @@ def video_url(youtubeId, format='mp4', timeout=cache_timeout):
|
||||||
fmt=35
|
fmt=35
|
||||||
elif format == 'webm':
|
elif format == 'webm':
|
||||||
streams = videos(youtubeId, 'webm')
|
streams = videos(youtubeId, 'webm')
|
||||||
return streams[max(streams.keys())]['url']
|
return get_url(streams[max(streams.keys())])
|
||||||
|
|
||||||
streams = videos(youtubeId)
|
streams = videos(youtubeId)
|
||||||
if str(fmt) in streams:
|
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'):
|
def find(query, max_results=10, offset=1, orderBy='relevance'):
|
||||||
query = quote(query)
|
query = quote(query)
|
||||||
|
|
Loading…
Reference in a new issue