mirror of https://github.com/yt-dlp/yt-dlp.git
[youtube] multiple subtitles in same language
Fixes: https://github.com/ytdl-org/youtube-dl/issues/21164 Related: #310, https://github.com/ytdl-org/youtube-dl/pull/26112
This commit is contained in:
parent
fe346461ff
commit
120916dac2
|
@ -1308,6 +1308,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
'url': 'WaOKSUlf4TM',
|
'url': 'WaOKSUlf4TM',
|
||||||
'only_matching': True
|
'only_matching': True
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
# multiple subtitles with same lang_code
|
||||||
|
'url': 'https://www.youtube.com/watch?v=wsQiKKfKxug',
|
||||||
|
'only_matching': True,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -2182,7 +2187,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
if pctr:
|
if pctr:
|
||||||
def process_language(container, base_url, lang_code, query):
|
def process_language(container, base_url, lang_code, query):
|
||||||
lang_subs = []
|
lang_subs = container.setdefault(lang_code, [])
|
||||||
for fmt in self._SUBTITLE_FORMATS:
|
for fmt in self._SUBTITLE_FORMATS:
|
||||||
query.update({
|
query.update({
|
||||||
'fmt': fmt,
|
'fmt': fmt,
|
||||||
|
@ -2191,14 +2196,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
'ext': fmt,
|
'ext': fmt,
|
||||||
'url': update_url_query(base_url, query),
|
'url': update_url_query(base_url, query),
|
||||||
})
|
})
|
||||||
container[lang_code] = lang_subs
|
|
||||||
|
|
||||||
for caption_track in (pctr.get('captionTracks') or []):
|
for caption_track in (pctr.get('captionTracks') or []):
|
||||||
base_url = caption_track.get('baseUrl')
|
base_url = caption_track.get('baseUrl')
|
||||||
if not base_url:
|
if not base_url:
|
||||||
continue
|
continue
|
||||||
if caption_track.get('kind') != 'asr':
|
if caption_track.get('kind') != 'asr':
|
||||||
lang_code = caption_track.get('languageCode')
|
lang_code = (
|
||||||
|
remove_start(caption_track.get('vssId') or '', '.').replace('.', '-')
|
||||||
|
or caption_track.get('languageCode'))
|
||||||
if not lang_code:
|
if not lang_code:
|
||||||
continue
|
continue
|
||||||
process_language(
|
process_language(
|
||||||
|
|
Loading…
Reference in New Issue