- def _extract_video(self, webpage, url_type):
- if url_type != 'embed':
- description = self._html_search_regex(
- [
- r'<div class="cne-video-description">(.+?)</div>',
- r'<div class="video-post-content">(.+?)</div>',
- ],
- webpage, 'description', fatal=False, flags=re.DOTALL)
+ def _extract_video_params(self, webpage):
+ query = {}
+ params = self._search_regex(
+ r'(?s)var params = {(.+?)}[;,]', webpage, 'player params', default=None)
+ if params:
+ query.update({
+ 'videoId': self._search_regex(r'videoId: [\'"](.+?)[\'"]', params, 'video id'),
+ 'playerId': self._search_regex(r'playerId: [\'"](.+?)[\'"]', params, 'player id'),
+ 'target': self._search_regex(r'target: [\'"](.+?)[\'"]', params, 'target'),
+ })
+ else:
+ params = extract_attributes(self._search_regex(
+ r'(<[^>]+data-js="video-player"[^>]+>)',
+ webpage, 'player params element'))
+ query.update({
+ 'videoId': params['data-video'],
+ 'playerId': params['data-player'],
+ 'target': params['id'],
+ })
+ return query
+
+ def _extract_video(self, params):
+ video_id = params['videoId']
+
+ video_info = None
+ if params.get('playerId'):
+ info_page = self._download_json(
+ 'http://player.cnevids.com/player/video.js',
+ video_id, 'Downloading video info', fatal=False, query=params)
+ if info_page:
+ video_info = info_page.get('video')
+ if not video_info:
+ info_page = self._download_webpage(
+ 'http://player.cnevids.com/player/loader.js',
+ video_id, 'Downloading loader info', query=params)