This commit is contained in:
j 2017-08-02 16:48:01 +02:00
parent 454d53d68a
commit b7b4b09f0f

View file

@ -46,14 +46,14 @@ def video_url(youtubeId, format='mp4', timeout=cache_timeout):
def get_video_info(id): def get_video_info(id):
eurl = get_url(id) eurl = get_url(id)
data = read_url(eurl) data = read_url(eurl).decode('utf-8')
t = re.compile('\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]').findall(data) t = re.compile('\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]').findall(data)
if t: if t:
t = t[0] t = t[0]
else: else:
raise IOError raise IOError
url = "http://www.youtube.com/get_video_info?&video_id=%s&el=$el&ps=default&eurl=%s&hl=en_US&t=%s" % (id, quote(eurl), quote(t)) url = "http://www.youtube.com/get_video_info?&video_id=%s&el=$el&ps=default&eurl=%s&hl=en_US&t=%s" % (id, quote(eurl), quote(t))
data = read_url(url) data = read_url(url).decode('utf-8')
info = {} info = {}
for part in data.split('&'): for part in data.split('&'):
key, value = part.split('=') key, value = part.split('=')