]>
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 | ||
faa6ef6b | 9 | |
25b51c78 PR |
10 | class JeuxVideoIE(InfoExtractor): |
11 | _VALID_URL = r'http://.*?\.jeuxvideo\.com/.*/(.*?)-\d+\.htm' | |
12 | ||
063fcc96 JMF |
13 | _TEST = { |
14 | 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', | |
15 | u'file': u'5182.mp4', | |
ba2d9f21 | 16 | u'md5': u'046e491afb32a8aaac1f44dd4ddd54ee', |
063fcc96 JMF |
17 | u'info_dict': { |
18 | u'title': u'GC 2013 : Tearaway nous présente ses papiers d\'identité', | |
19 | 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', | |
20 | }, | |
21 | } | |
22 | ||
25b51c78 PR |
23 | def _real_extract(self, url): |
24 | mobj = re.match(self._VALID_URL, url) | |
25 | title = re.match(self._VALID_URL, url).group(1) | |
26 | webpage = self._download_webpage(url, title) | |
faa6ef6b PH |
27 | xml_link = self._html_search_regex( |
28 | r'<param name="flashvars" value="config=(.*?)" />', | |
29 | webpage, u'config URL') | |
25b51c78 | 30 | |
faa6ef6b PH |
31 | video_id = self._search_regex( |
32 | r'http://www\.jeuxvideo\.com/config/\w+/\d+/(.*?)/\d+_player\.xml', | |
33 | xml_link, u'video ID') | |
25b51c78 | 34 | |
faa6ef6b PH |
35 | xml_config = self._download_webpage( |
36 | xml_link, title, u'Downloading XML config') | |
063fcc96 | 37 | config = xml.etree.ElementTree.fromstring(xml_config.encode('utf-8')) |
faa6ef6b PH |
38 | info_json = self._search_regex( |
39 | r'(?sm)<format\.json>(.*?)</format\.json>', | |
40 | xml_config, u'JSON information') | |
41 | info = json.loads(info_json)['versions'][0] | |
25b51c78 PR |
42 | |
43 | video_url = 'http://video720.jeuxvideo.com/' + info['file'] | |
44 | ||
faa6ef6b PH |
45 | return { |
46 | 'id': video_id, | |
47 | 'title': config.find('titre_video').text, | |
48 | 'ext': 'mp4', | |
49 | 'url': video_url, | |
50 | 'description': self._og_search_description(webpage), | |
51 | 'thumbnail': config.find('image').text, | |
52 | } |