mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-10 00:58:17 +02:00
[youtube] Add language names
Co-authored by: nixxo, tpikonen Based on: https://github.com/ytdl-org/youtube-dl/pull/26112 Closes: #310
This commit is contained in:
parent
2412044c90
commit
774d79cc4c
@ -2186,7 +2186,7 @@ def feed_entry(name):
|
||||
lambda x: x['captions']['playerCaptionsTracklistRenderer'], dict)
|
||||
subtitles = {}
|
||||
if pctr:
|
||||
def process_language(container, base_url, lang_code, query):
|
||||
def process_language(container, base_url, lang_code, sub_name, query):
|
||||
lang_subs = container.setdefault(lang_code, [])
|
||||
for fmt in self._SUBTITLE_FORMATS:
|
||||
query.update({
|
||||
@ -2195,6 +2195,7 @@ def process_language(container, base_url, lang_code, query):
|
||||
lang_subs.append({
|
||||
'ext': fmt,
|
||||
'url': update_url_query(base_url, query),
|
||||
'name': sub_name,
|
||||
})
|
||||
|
||||
for caption_track in (pctr.get('captionTracks') or []):
|
||||
@ -2208,7 +2209,9 @@ def process_language(container, base_url, lang_code, query):
|
||||
if not lang_code:
|
||||
continue
|
||||
process_language(
|
||||
subtitles, base_url, lang_code, {})
|
||||
subtitles, base_url, lang_code,
|
||||
try_get(caption_track, lambda x: x.get('name').get('simpleText')),
|
||||
{})
|
||||
continue
|
||||
automatic_captions = {}
|
||||
for translation_language in (pctr.get('translationLanguages') or []):
|
||||
@ -2217,6 +2220,7 @@ def process_language(container, base_url, lang_code, query):
|
||||
continue
|
||||
process_language(
|
||||
automatic_captions, base_url, translation_language_code,
|
||||
try_get(translation_language, lambda x: x['languageName']['simpleText']),
|
||||
{'tlang': translation_language_code})
|
||||
info['automatic_captions'] = automatic_captions
|
||||
info['subtitles'] = subtitles
|
||||
|
Loading…
Reference in New Issue
Block a user