mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-29 19:47:54 +01:00
[youtube] Fix download of auto-captions when subtitles are available
When invoked with --write-auto-sub (but without --write-sub), youtube-dl should only download automatic captions. However, for some videos with both automatic captions and manual subtitles (e.g. 2klmuggOElE; accessed on 16.04.2020), youtube-dl selects the manual subtitle track regardless. This commit makes _get_automatic_captions prefer a renderer['captionTracks'] entry with 'kind' == 'asr', if one is available, as the 'kind=asr' parameter also distinguishes the baseUrl's (but one could also filter by vssId.startswith('a.')).
This commit is contained in:
parent
00eb865b3c
commit
ef8c0ad835
@ -1519,6 +1519,14 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
if player_response:
|
if player_response:
|
||||||
renderer = player_response['captions']['playerCaptionsTracklistRenderer']
|
renderer = player_response['captions']['playerCaptionsTracklistRenderer']
|
||||||
base_url = renderer['captionTracks'][0]['baseUrl']
|
base_url = renderer['captionTracks'][0]['baseUrl']
|
||||||
|
# the first caption track might contain manual
|
||||||
|
# subtitles not auto-captions (e.g. 2klmuggOElE,
|
||||||
|
# accessed on 16.04.2020) so we look further in
|
||||||
|
# captionTracks and select a base_url from an
|
||||||
|
# explicitly marked asr track if one exists.
|
||||||
|
for track in renderer['captionTracks'][1:]:
|
||||||
|
if track.get('kind') == 'asr':
|
||||||
|
base_url = track['baseUrl']
|
||||||
sub_lang_list = []
|
sub_lang_list = []
|
||||||
for lang in renderer['translationLanguages']:
|
for lang in renderer['translationLanguages']:
|
||||||
lang_code = lang.get('languageCode')
|
lang_code = lang.get('languageCode')
|
||||||
|
Loading…
Reference in New Issue
Block a user