[youtube] fully fix #2857 with DASH stream

This commit is contained in:
Mort Yao 2020-12-26 19:02:47 +01:00
parent 6be1d0308e
commit 9a4d9ef94e
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -468,11 +468,16 @@ class YouTube(VideoExtractor):
for afmt in video_info['adaptive_fmts'][0].split(',')] for afmt in video_info['adaptive_fmts'][0].split(',')]
else: else:
try: try:
streams = json.loads(video_info['player_response'][0])['streamingData']['adaptiveFormats'] try:
streams = json.loads(video_info['player_response'][0])['streamingData']['adaptiveFormats']
except:
streams = ytInitialPlayerResponse['streamingData']['adaptiveFormats']
except: # no DASH stream at all except: # no DASH stream at all
return return
# streams without contentLength got broken urls, just remove them (#2767) # streams without contentLength got broken urls, just remove them (#2767)
streams = [stream for stream in streams if 'contentLength' in stream] streams = [stream for stream in streams if 'contentLength' in stream]
for stream in streams: for stream in streams:
stream['itag'] = str(stream['itag']) stream['itag'] = str(stream['itag'])
if 'qualityLabel' in stream: if 'qualityLabel' in stream: