From 240b7a81118ac99055d9311a3a0bf3ff8fddc256 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Mon, 18 Jan 2021 18:37:24 +0100 Subject: [PATCH] [youtube] fix extraction of caption tracks, close #2866 --- src/you_get/extractors/youtube.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/you_get/extractors/youtube.py b/src/you_get/extractors/youtube.py index 30297c75..e954b1f4 100644 --- a/src/you_get/extractors/youtube.py +++ b/src/you_get/extractors/youtube.py @@ -353,7 +353,10 @@ class YouTube(VideoExtractor): # Prepare caption tracks try: - caption_tracks = json.loads(ytplayer_config['args']['player_response'])['captions']['playerCaptionsTracklistRenderer']['captionTracks'] + try: + caption_tracks = json.loads(ytplayer_config['args']['player_response'])['captions']['playerCaptionsTracklistRenderer']['captionTracks'] + except: + caption_tracks = ytInitialPlayerResponse['captions']['playerCaptionsTracklistRenderer']['captionTracks'] for ct in caption_tracks: ttsurl, lang = ct['baseUrl'], ct['languageCode']