]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/jeuxvideo.py
Add support for https for all extractors as preventive and future-proof measure
[yt-dlp.git] / youtube_dl / extractor / jeuxvideo.py
CommitLineData
063fcc96
JMF
1# coding: utf-8
2
98dbee86
PH
3from __future__ import unicode_literals
4
25b51c78
PR
5import re
6
7from .common import InfoExtractor
8
faa6ef6b 9
25b51c78 10class JeuxVideoIE(InfoExtractor):
5886b38d 11 _VALID_URL = r'https?://.*?\.jeuxvideo\.com/.*/(.*?)\.htm'
25b51c78 12
01d115b0 13 _TESTS = [{
98dbee86
PH
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': {
054b99a3 17 'id': '114765',
98dbee86 18 'ext': 'mp4',
054b99a3
JMF
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.',
063fcc96 21 },
01d115b0
JMF
22 }, {
23 'url': 'http://www.jeuxvideo.com/videos/chroniques/434220/l-histoire-du-jeu-video-la-saturn.htm',
24 'only_matching': True,
25 }]
063fcc96 26
25b51c78
PR
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
f3682997 29 title = mobj.group(1)
25b51c78 30 webpage = self._download_webpage(url, title)
6744f36d 31 title = self._html_search_meta('name', webpage) or self._og_search_title(webpage)
054b99a3 32 config_url = self._html_search_regex(
1e501f6c 33 r'data-src(?:set-video)?="(/contenu/medias/video.php.*?)"',
98dbee86 34 webpage, 'config URL')
054b99a3 35 config_url = 'http://www.jeuxvideo.com' + config_url
5f6a1245 36
faa6ef6b 37 video_id = self._search_regex(
054b99a3
JMF
38 r'id=(\d+)',
39 config_url, 'video ID')
25b51c78 40
054b99a3
JMF
41 config = self._download_json(
42 config_url, title, 'Downloading JSON config')
5f6a1245 43
054b99a3
JMF
44 formats = [{
45 'url': source['file'],
46 'format_id': source['label'],
47 'resolution': source['label'],
48 } for source in reversed(config['sources'])]
25b51c78 49
faa6ef6b
PH
50 return {
51 'id': video_id,
054b99a3
JMF
52 'title': title,
53 'formats': formats,
faa6ef6b 54 'description': self._og_search_description(webpage),
054b99a3 55 'thumbnail': config.get('image'),
faa6ef6b 56 }