- title = self._html_search_regex(
- r'<div id="bg_brandableContent">.+?<h1>(.+?)</h1>',
- webpage, 'title', flags=re.DOTALL)
-
- sd_url = self._html_search_regex(
- r'{\"url\":\"([^"]+?)\",\"hd\":false',
- webpage, 'sd_url').replace('\\', '')
-
- formats = [{'format_id': 'sd', 'url': sd_url, 'quality': -2}]
-
- hd_url = self._html_search_regex(
- r'{\"url\":\"([^"]+?)\",\"hd\":true',
- webpage, 'hd_url', default=None)
- if hd_url:
- hd_url = hd_url.replace('\\', '')
- formats.append({'format_id': 'hd', 'url': hd_url, 'quality': -1})
-
- return {
- 'id': video_id,
- 'title': title,
- 'formats': formats,
- 'ext': 'mp4'
- }
+ player = self._search_regex(
+ r'p4_video_player(?:_iframe)?\("video_\d+_container"\s*,(.+?)\);\s*\}',
+ webpage, 'player')
+
+ player_json = self._parse_json(
+ '[%s]' % player, video_id,
+ transform_source=lambda s: s.replace('undefined,', ''))
+
+ formats = None
+ result = None
+
+ for v in player_json:
+ if isinstance(v, list) and not formats:
+ formats = [{
+ 'url': f['url'],
+ 'format': 'hd' if f.get('hd') else 'sd',
+ 'width': int_or_none(f.get('size_x')),
+ 'height': int_or_none(f.get('size_y')),
+ 'tbr': int_or_none(f.get('bitrate')),
+ } for f in v]
+ self._sort_formats(formats)
+ elif isinstance(v, dict) and not result:
+ result = {
+ 'id': video_id,
+ 'title': v['videopartname'].strip(),
+ 'description': v.get('videotitle'),
+ 'duration': int_or_none(v.get('videoduration') or v.get('episodeduration')),
+ 'upload_date': unified_strdate(v.get('clipreleasetime')),
+ 'uploader': v.get('channel'),
+ }
+
+ result['formats'] = formats
+
+ return result