[youtube] fix dash-mpd for live streams (no yt:contentLength field)

This commit is contained in:
Mort Yao 2016-11-26 12:35:50 +01:00
parent e65c2d23a0
commit 03266c030a
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -258,11 +258,17 @@ class YouTube(VideoExtractor):
burls = rep.getElementsByTagName('BaseURL')
dash_mp4_a_url = burls[0].firstChild.nodeValue
dash_mp4_a_size = burls[0].getAttribute('yt:contentLength')
if not dash_mp4_a_size:
try: dash_mp4_a_size = url_size(dash_mp4_a_url)
except: continue
elif mimeType == 'audio/webm':
rep = aset.getElementsByTagName('Representation')[-1]
burls = rep.getElementsByTagName('BaseURL')
dash_webm_a_url = burls[0].firstChild.nodeValue
dash_webm_a_size = burls[0].getAttribute('yt:contentLength')
if not dash_webm_a_size:
try: dash_webm_a_size = url_size(dash_webm_a_url)
except: continue
elif mimeType == 'video/mp4':
for rep in aset.getElementsByTagName('Representation'):
w = int(rep.getAttribute('width'))
@ -271,6 +277,9 @@ class YouTube(VideoExtractor):
burls = rep.getElementsByTagName('BaseURL')
dash_url = burls[0].firstChild.nodeValue
dash_size = burls[0].getAttribute('yt:contentLength')
if not dash_size:
try: dash_size = url_size(dash_url)
except: continue
self.dash_streams[itag] = {
'quality': '%sx%s' % (w, h),
'itag': itag,
@ -288,6 +297,9 @@ class YouTube(VideoExtractor):
burls = rep.getElementsByTagName('BaseURL')
dash_url = burls[0].firstChild.nodeValue
dash_size = burls[0].getAttribute('yt:contentLength')
if not dash_size:
try: dash_size = url_size(dash_url)
except: continue
self.dash_streams[itag] = {
'quality': '%sx%s' % (w, h),
'itag': itag,