- 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'),
- }
+
+ webpage = self._download_webpage(url, text_id)
+ sohu_video_info_str = self._search_regex(
+ r'var\s+sohuVideoInfo\s*=\s*({[^}]+});', webpage, 'Sohu video info', default=None)
+ if sohu_video_info_str:
+ sohu_video_info = self._parse_json(
+ sohu_video_info_str, text_id, transform_source=js_to_json)
+ return self.url_result(sohu_video_info['url'], 'Sohu')
+
+ 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'),
+ }