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