]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/jeuxvideo.py
[bitchute] Fix test (#758)
[yt-dlp.git] / yt_dlp / extractor / jeuxvideo.py
CommitLineData
063fcc96
JMF
1# coding: utf-8
2
98dbee86
PH
3from __future__ import unicode_literals
4
25b51c78
PR
5
6from .common import InfoExtractor
7
faa6ef6b 8
25b51c78 9class JeuxVideoIE(InfoExtractor):
5886b38d 10 _VALID_URL = r'https?://.*?\.jeuxvideo\.com/.*/(.*?)\.htm'
25b51c78 11
01d115b0 12 _TESTS = [{
98dbee86
PH
13 'url': 'http://www.jeuxvideo.com/reportages-videos-jeux/0004/00046170/tearaway-playstation-vita-gc-2013-tearaway-nous-presente-ses-papiers-d-identite-00115182.htm',
14 'md5': '046e491afb32a8aaac1f44dd4ddd54ee',
15 'info_dict': {
054b99a3 16 'id': '114765',
98dbee86 17 'ext': 'mp4',
054b99a3
JMF
18 'title': 'Tearaway : GC 2013 : Tearaway nous présente ses papiers d\'identité',
19 '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 20 },
01d115b0
JMF
21 }, {
22 'url': 'http://www.jeuxvideo.com/videos/chroniques/434220/l-histoire-du-jeu-video-la-saturn.htm',
23 'only_matching': True,
24 }]
063fcc96 25
25b51c78 26 def _real_extract(self, url):
5ad28e7f 27 mobj = self._match_valid_url(url)
f3682997 28 title = mobj.group(1)
25b51c78 29 webpage = self._download_webpage(url, title)
6744f36d 30 title = self._html_search_meta('name', webpage) or self._og_search_title(webpage)
054b99a3 31 config_url = self._html_search_regex(
197224b7 32 r'data-src(?:set-video)?="(/contenu/medias/video\.php.*?)"',
98dbee86 33 webpage, 'config URL')
054b99a3 34 config_url = 'http://www.jeuxvideo.com' + config_url
5f6a1245 35
faa6ef6b 36 video_id = self._search_regex(
054b99a3
JMF
37 r'id=(\d+)',
38 config_url, 'video ID')
25b51c78 39
054b99a3
JMF
40 config = self._download_json(
41 config_url, title, 'Downloading JSON config')
5f6a1245 42
054b99a3
JMF
43 formats = [{
44 'url': source['file'],
45 'format_id': source['label'],
46 'resolution': source['label'],
47 } for source in reversed(config['sources'])]
25b51c78 48
faa6ef6b
PH
49 return {
50 'id': video_id,
054b99a3
JMF
51 'title': title,
52 'formats': formats,
faa6ef6b 53 'description': self._og_search_description(webpage),
054b99a3 54 'thumbnail': config.get('image'),
faa6ef6b 55 }