]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/jeuxvideo.py
d0720ff561c16e8c0816c5ff7ab333e54c297dbc
[youtubedl] / youtube_dl / extractor / jeuxvideo.py
1 # coding: utf-8
2
3 from __future__ import unicode_literals
4
5 import re
6
7 from .common import InfoExtractor
8
9
10 class JeuxVideoIE(InfoExtractor):
11 _VALID_URL = r'http://.*?\.jeuxvideo\.com/.*/(.*?)-\d+\.htm'
12
13 _TEST = {
14 'url': 'http://www.jeuxvideo.com/reportages-videos-jeux/0004/00046170/tearaway-playstation-vita-gc-2013-tearaway-nous-presente-ses-papiers-d-identite-00115182.htm',
15 'md5': '046e491afb32a8aaac1f44dd4ddd54ee',
16 'info_dict': {
17 'id': '114765',
18 'ext': 'mp4',
19 'title': 'Tearaway : GC 2013 : Tearaway nous présente ses papiers d\'identité',
20 'description': 'Lorsque les développeurs de LittleBigPlanet proposent un nouveau titre, on ne peut que s\'attendre à un résultat original et fort attrayant.',
21 },
22 }
23
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
26 title = mobj.group(1)
27 webpage = self._download_webpage(url, title)
28 title = self._html_search_meta('name', webpage)
29 config_url = self._html_search_regex(
30 r'data-src="(/contenu/medias/video.php.*?)"',
31 webpage, 'config URL')
32 config_url = 'http://www.jeuxvideo.com' + config_url
33
34 video_id = self._search_regex(
35 r'id=(\d+)',
36 config_url, 'video ID')
37
38 config = self._download_json(
39 config_url, title, 'Downloading JSON config')
40
41 formats = [{
42 'url': source['file'],
43 'format_id': source['label'],
44 'resolution': source['label'],
45 } for source in reversed(config['sources'])]
46
47 return {
48 'id': video_id,
49 'title': title,
50 'formats': formats,
51 'description': self._og_search_description(webpage),
52 'thumbnail': config.get('image'),
53 }