[ted] Fix subtitles extraction (closes #13628, closes #13629)

pull/2/head
Sergey M․ 7 years ago
parent 3615bfe1b4
commit f2bb33a986
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

@ -271,20 +271,22 @@ class TEDIE(InfoExtractor):
} }
def _get_subtitles(self, video_id, talk_info): def _get_subtitles(self, video_id, talk_info):
languages = [lang['languageCode'] for lang in talk_info.get('languages', [])]
if languages:
sub_lang_list = {} sub_lang_list = {}
for l in languages: for language in try_get(
sub_lang_list[l] = [ talk_info,
(lambda x: x['downloads']['languages'],
lambda x: x['languages']), list):
lang_code = language.get('languageCode') or language.get('ianaCode')
if not lang_code:
continue
sub_lang_list[lang_code] = [
{ {
'url': 'http://www.ted.com/talks/subtitles/id/%s/lang/%s/format/%s' % (video_id, l, ext), 'url': 'http://www.ted.com/talks/subtitles/id/%s/lang/%s/format/%s' % (video_id, lang_code, ext),
'ext': ext, 'ext': ext,
} }
for ext in ['ted', 'srt'] for ext in ['ted', 'srt']
] ]
return sub_lang_list return sub_lang_list
else:
return {}
def _watch_info(self, url, name): def _watch_info(self, url, name):
webpage = self._download_webpage(url, name) webpage = self._download_webpage(url, name)

Loading…
Cancel
Save