[canvas] Improve subtitles (Closes #8537)

This commit is contained in:
Sergey M․ 2016-02-15 20:54:01 +06:00
parent 8d3eeb36d7
commit fd7a3ea4a4

View File

@ -55,13 +55,12 @@ class CanvasIE(InfoExtractor):
self._sort_formats(formats) self._sort_formats(formats)
subtitles = {} subtitles = {}
for target in data['subtitleUrls']: subtitle_urls = data.get('subtitleUrls')
format_url, format_type = target.get('url'), target.get('type') if isinstance(subtitle_urls, list):
if format_type == 'CLOSED': for subtitle in subtitle_urls:
subtitles['nl'] = [{ subtitle_url = subtitle.get('url')
'ext': 'vtt', if subtitle_url and subtitle.get('type') == 'CLOSED':
'url': format_url, subtitles.setdefault('nl', []).append({'url': subtitle_url})
}]
return { return {
'id': video_id, 'id': video_id,