[youtube] fix extraction of caption tracks, close #2866

This commit is contained in:
Mort Yao 2021-01-18 18:37:24 +01:00
parent 81d416d1cd
commit 240b7a8111
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -352,8 +352,11 @@ class YouTube(VideoExtractor):
for _ in stream['signatureCipher'].split('&')])) for _ in stream['signatureCipher'].split('&')]))
# Prepare caption tracks # Prepare caption tracks
try:
try: try:
caption_tracks = json.loads(ytplayer_config['args']['player_response'])['captions']['playerCaptionsTracklistRenderer']['captionTracks'] caption_tracks = json.loads(ytplayer_config['args']['player_response'])['captions']['playerCaptionsTracklistRenderer']['captionTracks']
except:
caption_tracks = ytInitialPlayerResponse['captions']['playerCaptionsTracklistRenderer']['captionTracks']
for ct in caption_tracks: for ct in caption_tracks:
ttsurl, lang = ct['baseUrl'], ct['languageCode'] ttsurl, lang = ct['baseUrl'], ct['languageCode']