+ title = re.sub(r' - 搜狐视频$', '', self._og_search_title(webpage))
+
+ vid = self._html_search_regex(
+ r'var vid ?= ?["\'](\d+)["\']',
+ webpage, 'video path')
+ vid_data = _fetch_data(vid, mytv)
+ if vid_data['play'] != 1:
+ if vid_data.get('status') == 12:
+ raise ExtractorError(
+ 'Sohu said: There\'s something wrong in the video.',
+ expected=True)
+ else:
+ raise ExtractorError(
+ 'Sohu said: The video is only licensed to users in Mainland China.',
+ expected=True)
+
+ formats_json = {}
+ for format_id in ('nor', 'high', 'super', 'ori', 'h2644k', 'h2654k'):
+ vid_id = vid_data['data'].get('%sVid' % format_id)
+ if not vid_id:
+ continue
+ vid_id = compat_str(vid_id)
+ formats_json[format_id] = vid_data if vid == vid_id else _fetch_data(vid_id, mytv)
+
+ part_count = vid_data['data']['totalBlocks']
+
+ playlist = []
+ for i in range(part_count):
+ formats = []
+ for format_id, format_data in formats_json.items():
+ data = format_data['data']
+
+ # URLs starts with http://newflv.sohu.ccgslb.net/ is not usable
+ # so retry until got a working URL
+ video_url = 'newflv.sohu.ccgslb.net'
+ retries = 0
+ while 'newflv.sohu.ccgslb.net' in video_url and retries < 5:
+ download_note = 'Download information from CDN gateway for format ' + format_id
+ if retries > 0:
+ download_note += ' (retry #%d)' % retries
+ retries += 1
+ cdn_info = self._download_json(
+ 'http://data.vod.itc.cn/cdnList?new=' + data['su'][i],
+ video_id, download_note)
+ video_url = cdn_info['url']
+
+ formats.append({
+ 'url': video_url,
+ 'format_id': format_id,
+ 'filesize': data['clipsBytes'][i],
+ 'width': data['width'],
+ 'height': data['height'],
+ 'fps': data['fps'],
+ })
+ self._sort_formats(formats)
+
+ playlist.append({
+ 'id': '%s_part%d' % (video_id, i + 1),
+ 'title': title,
+ 'duration': vid_data['data']['clipsDuration'][i],
+ 'formats': formats,
+ })
+
+ if len(playlist) == 1:
+ info = playlist[0]
+ info['id'] = video_id
+ else: