diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index a61753b17..931f31724 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -247,6 +247,8 @@ class InfoExtractor(object): entry and one of: * "data": The subtitles file contents * "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 automatic_captions: Like 'subtitles', used by the YoutubeIE for automatically generated captions diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index c27f2cd95..d58a49fd7 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1448,18 +1448,21 @@ class YoutubeIE(YoutubeBaseInfoExtractor): for track in subs_doc.findall('track'): lang = track.attrib['lang_code'] if lang in sub_lang_list: - continue - sub_formats = [] + sub_formats = sub_lang_list[lang] + else: + sub_formats = [] for ext in self._SUBTITLE_FORMATS: + name = track.attrib['name'] params = compat_urllib_parse_urlencode({ 'lang': lang, 'v': video_id, 'fmt': ext, - 'name': track.attrib['name'].encode('utf-8'), + 'name': name.encode('utf-8'), }) sub_formats.append({ 'url': 'https://www.youtube.com/api/timedtext?' + params, 'ext': ext, + 'name': name, }) sub_lang_list[lang] = sub_formats if not sub_lang_list: