]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/jeuxvideo.py
debian/control: Add recommends on aria2 | wget | curl to use external downloaders.
[youtubedl] / youtube_dl / extractor / jeuxvideo.py
1 # coding: utf-8
2
3 from __future__ import unicode_literals
4
5 import json
6 import re
7
8 from .common import InfoExtractor
9
10
11 class JeuxVideoIE(InfoExtractor):
12 _VALID_URL = r'http://.*?\.jeuxvideo\.com/.*/(.*?)-\d+\.htm'
13
14 _TEST = {
15 'url': 'http://www.jeuxvideo.com/reportages-videos-jeux/0004/00046170/tearaway-playstation-vita-gc-2013-tearaway-nous-presente-ses-papiers-d-identite-00115182.htm',
16 'md5': '046e491afb32a8aaac1f44dd4ddd54ee',
17 'info_dict': {
18 'id': '5182',
19 'ext': 'mp4',
20 'title': 'GC 2013 : Tearaway nous présente ses papiers d\'identité',
21 'description': 'Lorsque les développeurs de LittleBigPlanet proposent un nouveau titre, on ne peut que s\'attendre à un résultat original et fort attrayant.\n',
22 },
23 }
24
25 def _real_extract(self, url):
26 mobj = re.match(self._VALID_URL, url)
27 title = mobj.group(1)
28 webpage = self._download_webpage(url, title)
29 xml_link = self._html_search_regex(
30 r'<param name="flashvars" value="config=(.*?)" />',
31 webpage, 'config URL')
32
33 video_id = self._search_regex(
34 r'http://www\.jeuxvideo\.com/config/\w+/\d+/(.*?)/\d+_player\.xml',
35 xml_link, 'video ID')
36
37 config = self._download_xml(
38 xml_link, title, 'Downloading XML config')
39 info_json = config.find('format.json').text
40 info = json.loads(info_json)['versions'][0]
41
42 video_url = 'http://video720.jeuxvideo.com/' + info['file']
43
44 return {
45 'id': video_id,
46 'title': config.find('titre_video').text,
47 'ext': 'mp4',
48 'url': video_url,
49 'description': self._og_search_description(webpage),
50 'thumbnail': config.find('image').text,
51 }