- m_download = re.search(r'<param name="flashvars" value="config=(.*?)" />', webpage)
-
- xml_link = m_download.group(1)
-
- id = re.search(r'http://www.jeuxvideo.com/config/\w+/0011/(.*?)/\d+_player\.xml', xml_link).group(1)
-
- xml_config = self._download_webpage(xml_link, title,
- 'Downloading XML config')
- config = xml.etree.ElementTree.fromstring(xml_config.encode('utf-8'))
- info = re.search(r'<format\.json>(.*?)</format\.json>',
- xml_config, re.MULTILINE|re.DOTALL).group(1)
- info = json.loads(info)['versions'][0]
-
- video_url = 'http://video720.jeuxvideo.com/' + info['file']
-
- return {'id': id,
- 'title' : config.find('titre_video').text,
- 'ext' : 'mp4',
- 'url' : video_url,
- 'description': self._og_search_description(webpage),
- 'thumbnail': config.find('image').text,
- }
+ title = self._html_search_meta('name', webpage) or self._og_search_title(webpage)
+ config_url = self._html_search_regex(
+ r'data-src(?:set-video)?="(/contenu/medias/video.php.*?)"',
+ webpage, 'config URL')
+ config_url = 'http://www.jeuxvideo.com' + config_url
+
+ video_id = self._search_regex(
+ r'id=(\d+)',
+ config_url, 'video ID')
+
+ config = self._download_json(
+ config_url, title, 'Downloading JSON config')
+
+ formats = [{
+ 'url': source['file'],
+ 'format_id': source['label'],
+ 'resolution': source['label'],
+ } for source in reversed(config['sources'])]
+
+ return {
+ 'id': video_id,
+ 'title': title,
+ 'formats': formats,
+ 'description': self._og_search_description(webpage),
+ 'thumbnail': config.get('image'),
+ }