1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-29 19:47:54 +01:00

[youtube] Return sub name in subtitle dict

Document the subtitles 'name' key in extractor/common.py
This commit is contained in:
Teemu Ikonen 2020-07-21 21:23:15 +03:00
parent a115e07594
commit c23c35c9c1
2 changed files with 8 additions and 3 deletions

View File

@ -247,6 +247,8 @@ class InfoExtractor(object):
entry and one of: entry and one of:
* "data": The subtitles file contents * "data": The subtitles file contents
* "url": A URL pointing to the subtitles file * "url": A URL pointing to the subtitles file
* "name": (optional) Name or description of the subtitles, used
when there are more than one subtitles file for this language
"ext" will be calculated from URL if missing "ext" will be calculated from URL if missing
automatic_captions: Like 'subtitles', used by the YoutubeIE for automatic_captions: Like 'subtitles', used by the YoutubeIE for
automatically generated captions automatically generated captions

View File

@ -1448,18 +1448,21 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
for track in subs_doc.findall('track'): for track in subs_doc.findall('track'):
lang = track.attrib['lang_code'] lang = track.attrib['lang_code']
if lang in sub_lang_list: if lang in sub_lang_list:
continue sub_formats = sub_lang_list[lang]
sub_formats = [] else:
sub_formats = []
for ext in self._SUBTITLE_FORMATS: for ext in self._SUBTITLE_FORMATS:
name = track.attrib['name']
params = compat_urllib_parse_urlencode({ params = compat_urllib_parse_urlencode({
'lang': lang, 'lang': lang,
'v': video_id, 'v': video_id,
'fmt': ext, 'fmt': ext,
'name': track.attrib['name'].encode('utf-8'), 'name': name.encode('utf-8'),
}) })
sub_formats.append({ sub_formats.append({
'url': 'https://www.youtube.com/api/timedtext?' + params, 'url': 'https://www.youtube.com/api/timedtext?' + params,
'ext': ext, 'ext': ext,
'name': name,
}) })
sub_lang_list[lang] = sub_formats sub_lang_list[lang] = sub_formats
if not sub_lang_list: if not sub_lang_list: