mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 12:01:28 +00:00
support new json3 captions
This commit is contained in:
parent
f5863a3ea0
commit
7e1cf1a48d
|
@ -549,7 +549,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
'396': {'acodec': 'none', 'vcodec': 'av01.0.05M.08'},
|
'396': {'acodec': 'none', 'vcodec': 'av01.0.05M.08'},
|
||||||
'397': {'acodec': 'none', 'vcodec': 'av01.0.05M.08'},
|
'397': {'acodec': 'none', 'vcodec': 'av01.0.05M.08'},
|
||||||
}
|
}
|
||||||
_SUBTITLE_FORMATS = ('srv1', 'srv2', 'srv3', 'ttml', 'vtt')
|
_SUBTITLE_FORMATS = ('srv1', 'srv2', 'srv3', 'ttml', 'vtt', 'json3')
|
||||||
|
|
||||||
_GEO_BYPASS = False
|
_GEO_BYPASS = False
|
||||||
|
|
||||||
|
@ -1560,14 +1560,21 @@ def make_captions(sub_url, sub_langs):
|
||||||
player_response, video_id, fatal=False)
|
player_response, video_id, fatal=False)
|
||||||
if player_response:
|
if player_response:
|
||||||
renderer = player_response['captions']['playerCaptionsTracklistRenderer']
|
renderer = player_response['captions']['playerCaptionsTracklistRenderer']
|
||||||
base_url = renderer['captionTracks'][0]['baseUrl']
|
caption_tracks = renderer['captionTracks']
|
||||||
sub_lang_list = []
|
for caption_track in caption_tracks:
|
||||||
for lang in renderer['translationLanguages']:
|
if 'kind' not in caption_track:
|
||||||
lang_code = lang.get('languageCode')
|
# not an automatic transcription
|
||||||
if lang_code:
|
continue
|
||||||
sub_lang_list.append(lang_code)
|
base_url = caption_track['baseUrl']
|
||||||
return make_captions(base_url, sub_lang_list)
|
sub_lang_list = []
|
||||||
|
for lang in renderer['translationLanguages']:
|
||||||
|
lang_code = lang.get('languageCode')
|
||||||
|
if lang_code:
|
||||||
|
sub_lang_list.append(lang_code)
|
||||||
|
return make_captions(base_url, sub_lang_list)
|
||||||
|
|
||||||
|
self._downloader.report_warning("Couldn't find automatic captions for %s" % video_id)
|
||||||
|
return {}
|
||||||
# Some videos don't provide ttsurl but rather caption_tracks and
|
# Some videos don't provide ttsurl but rather caption_tracks and
|
||||||
# caption_translation_languages (e.g. 20LmZk1hakA)
|
# caption_translation_languages (e.g. 20LmZk1hakA)
|
||||||
# Does not used anymore as of 22.06.2017
|
# Does not used anymore as of 22.06.2017
|
||||||
|
|
Loading…
Reference in a new issue