- info_page = self._download_webpage('http://vxml.56.com/json/%s/' % text_id,
- text_id, u'Downloading video info')
- info = json.loads(info_page)['info']
- best_format = sorted(info['rfiles'], key=lambda f: int(f['filesize']))[-1]
- video_url = best_format['url']
-
- return {'id': info['vid'],
- 'title': info['Subject'],
- 'url': video_url,
- 'ext': determine_ext(video_url),
- 'thumbnail': info.get('bimg') or info.get('img'),
- }
+
+ page = self._download_json(
+ 'http://vxml.56.com/json/%s/' % text_id, text_id, 'Downloading video info')
+
+ info = page['info']
+
+ formats = [
+ {
+ 'format_id': f['type'],
+ 'filesize': int(f['filesize']),
+ 'url': f['url']
+ } for f in info['rfiles']
+ ]
+ self._sort_formats(formats)
+
+ return {
+ 'id': info['vid'],
+ 'title': info['Subject'],
+ 'duration': int(info['duration']) / 1000.0,
+ 'formats': formats,
+ 'thumbnail': info.get('bimg') or info.get('img'),
+ }