]>
Commit | Line | Data |
---|---|---|
063fcc96 JMF |
1 | # coding: utf-8 |
2 | ||
25b51c78 PR |
3 | import json |
4 | import re | |
063fcc96 | 5 | import xml.etree.ElementTree |
25b51c78 PR |
6 | |
7 | from .common import InfoExtractor | |
8 | ||
9 | class JeuxVideoIE(InfoExtractor): | |
10 | _VALID_URL = r'http://.*?\.jeuxvideo\.com/.*/(.*?)-\d+\.htm' | |
11 | ||
063fcc96 JMF |
12 | _TEST = { |
13 | u'url': u'http://www.jeuxvideo.com/reportages-videos-jeux/0004/00046170/tearaway-playstation-vita-gc-2013-tearaway-nous-presente-ses-papiers-d-identite-00115182.htm', | |
14 | u'file': u'5182.mp4', | |
ba2d9f21 | 15 | u'md5': u'046e491afb32a8aaac1f44dd4ddd54ee', |
063fcc96 JMF |
16 | u'info_dict': { |
17 | u'title': u'GC 2013 : Tearaway nous présente ses papiers d\'identité', | |
18 | u'description': u'Lorsque les développeurs de LittleBigPlanet proposent un nouveau titre, on ne peut que s\'attendre à un résultat original et fort attrayant.\n', | |
19 | }, | |
20 | } | |
21 | ||
25b51c78 PR |
22 | def _real_extract(self, url): |
23 | mobj = re.match(self._VALID_URL, url) | |
24 | title = re.match(self._VALID_URL, url).group(1) | |
25 | webpage = self._download_webpage(url, title) | |
26 | m_download = re.search(r'<param name="flashvars" value="config=(.*?)" />', webpage) | |
27 | ||
28 | xml_link = m_download.group(1) | |
29 | ||
30 | id = re.search(r'http://www.jeuxvideo.com/config/\w+/0011/(.*?)/\d+_player\.xml', xml_link).group(1) | |
31 | ||
32 | xml_config = self._download_webpage(xml_link, title, | |
33 | 'Downloading XML config') | |
063fcc96 | 34 | config = xml.etree.ElementTree.fromstring(xml_config.encode('utf-8')) |
25b51c78 PR |
35 | info = re.search(r'<format\.json>(.*?)</format\.json>', |
36 | xml_config, re.MULTILINE|re.DOTALL).group(1) | |
37 | info = json.loads(info)['versions'][0] | |
38 | ||
39 | video_url = 'http://video720.jeuxvideo.com/' + info['file'] | |
40 | ||
063fcc96 JMF |
41 | return {'id': id, |
42 | 'title' : config.find('titre_video').text, | |
43 | 'ext' : 'mp4', | |
44 | 'url' : video_url, | |
45 | 'description': self._og_search_description(webpage), | |
46 | 'thumbnail': config.find('image').text, | |
47 | } |