0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-26 02:55:17 +00: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:
pukkandan 2021-05-13 16:49:40 +05:30
parent 2412044c90
commit 774d79cc4c
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698

View file

@ -2186,7 +2186,7 @@ def feed_entry(name):
lambda x: x['captions']['playerCaptionsTracklistRenderer'], dict) lambda x: x['captions']['playerCaptionsTracklistRenderer'], dict)
subtitles = {} subtitles = {}
if pctr: 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, []) lang_subs = container.setdefault(lang_code, [])
for fmt in self._SUBTITLE_FORMATS: for fmt in self._SUBTITLE_FORMATS:
query.update({ query.update({
@ -2195,6 +2195,7 @@ def process_language(container, base_url, lang_code, query):
lang_subs.append({ lang_subs.append({
'ext': fmt, 'ext': fmt,
'url': update_url_query(base_url, query), 'url': update_url_query(base_url, query),
'name': sub_name,
}) })
for caption_track in (pctr.get('captionTracks') or []): 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: if not lang_code:
continue continue
process_language( process_language(
subtitles, base_url, lang_code, {}) subtitles, base_url, lang_code,
try_get(caption_track, lambda x: x.get('name').get('simpleText')),
{})
continue continue
automatic_captions = {} automatic_captions = {}
for translation_language in (pctr.get('translationLanguages') or []): for translation_language in (pctr.get('translationLanguages') or []):
@ -2217,6 +2220,7 @@ def process_language(container, base_url, lang_code, query):
continue continue
process_language( process_language(
automatic_captions, base_url, translation_language_code, automatic_captions, base_url, translation_language_code,
try_get(translation_language, lambda x: x['languageName']['simpleText']),
{'tlang': translation_language_code}) {'tlang': translation_language_code})
info['automatic_captions'] = automatic_captions info['automatic_captions'] = automatic_captions
info['subtitles'] = subtitles info['subtitles'] = subtitles