]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/jeuxvideo.py
Merge remote-tracking branch 'h-collector/master'
[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 json
6import re
7
8from .common import InfoExtractor
9
faa6ef6b 10
25b51c78
PR
11class JeuxVideoIE(InfoExtractor):
12 _VALID_URL = r'http://.*?\.jeuxvideo\.com/.*/(.*?)-\d+\.htm'
13
063fcc96 14 _TEST = {
98dbee86
PH
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',
063fcc96
JMF
22 },
23 }
24
25b51c78
PR
25 def _real_extract(self, url):
26 mobj = re.match(self._VALID_URL, url)
f3682997 27 title = mobj.group(1)
25b51c78 28 webpage = self._download_webpage(url, title)
faa6ef6b
PH
29 xml_link = self._html_search_regex(
30 r'<param name="flashvars" value="config=(.*?)" />',
98dbee86 31 webpage, 'config URL')
5f6a1245 32
faa6ef6b
PH
33 video_id = self._search_regex(
34 r'http://www\.jeuxvideo\.com/config/\w+/\d+/(.*?)/\d+_player\.xml',
98dbee86 35 xml_link, 'video ID')
25b51c78 36
e26f8712 37 config = self._download_xml(
98dbee86 38 xml_link, title, 'Downloading XML config')
e26f8712 39 info_json = config.find('format.json').text
faa6ef6b 40 info = json.loads(info_json)['versions'][0]
5f6a1245 41
25b51c78
PR
42 video_url = 'http://video720.jeuxvideo.com/' + info['file']
43
faa6ef6b
PH
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 }