From 9a4d9ef94e5a00666118d0c2c845c16266f7dbb5 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sat, 26 Dec 2020 19:02:47 +0100 Subject: [PATCH] [youtube] fully fix #2857 with DASH stream --- src/you_get/extractors/youtube.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/you_get/extractors/youtube.py b/src/you_get/extractors/youtube.py index 9485b876..30297c75 100644 --- a/src/you_get/extractors/youtube.py +++ b/src/you_get/extractors/youtube.py @@ -468,11 +468,16 @@ class YouTube(VideoExtractor): for afmt in video_info['adaptive_fmts'][0].split(',')] else: 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 return + # streams without contentLength got broken urls, just remove them (#2767) streams = [stream for stream in streams if 'contentLength' in stream] + for stream in streams: stream['itag'] = str(stream['itag']) if 'qualityLabel' in stream: