Skip to content

Commit

Permalink
[ooyala] extract subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
remitamine committed May 23, 2016
1 parent 05b651e commit e8593f3
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions youtube_dl/extractor/ooyala.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ def _extract(self, content_tree_url, video_id, domain='example.org'):
metadata = content_tree[list(content_tree)[0]]
embed_code = metadata['embed_code']
pcode = metadata.get('asset_pcode') or embed_code
video_info = {
'id': embed_code,
'title': metadata['title'],
'description': metadata.get('description'),
'thumbnail': metadata.get('thumbnail_image') or metadata.get('promo_image'),
'duration': float_or_none(metadata.get('duration'), 1000),
}
title = metadata['title']

urls = []
formats = []
Expand Down Expand Up @@ -78,8 +72,24 @@ def _extract(self, content_tree_url, video_id, domain='example.org'):
self.IE_NAME, cur_auth_data['message']), expected=True)
self._sort_formats(formats)

video_info['formats'] = formats
return video_info
subtitles = {}
for lang, sub in metadata.get('closed_captions_vtt', {}).get('captions', {}).items():
sub_url = sub.get('url')
if not sub_url:
continue
subtitles[lang] = [{
'url': sub_url,
}]

return {
'id': embed_code,
'title': title,
'description': metadata.get('description'),
'thumbnail': metadata.get('thumbnail_image') or metadata.get('promo_image'),
'duration': float_or_none(metadata.get('duration'), 1000),
'subtitles': subtitles,
'formats': formats,
}


class OoyalaIE(OoyalaBaseIE):
Expand Down

0 comments on commit e8593f3

Please sign in to comment.