]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/jeuxvideo.py
Download videos from jeuxvideo.com
[yt-dlp.git] / youtube_dl / extractor / jeuxvideo.py
1 import json
2 import re
3
4 from .common import InfoExtractor
5
6 class JeuxVideoIE(InfoExtractor):
7 _VALID_URL = r'http://.*?\.jeuxvideo\.com/.*/(.*?)-\d+\.htm'
8
9 def _real_extract(self, url):
10 mobj = re.match(self._VALID_URL, url)
11 title = re.match(self._VALID_URL, url).group(1)
12 webpage = self._download_webpage(url, title)
13 m_download = re.search(r'<param name="flashvars" value="config=(.*?)" />', webpage)
14
15 xml_link = m_download.group(1)
16
17 id = re.search(r'http://www.jeuxvideo.com/config/\w+/0011/(.*?)/\d+_player\.xml', xml_link).group(1)
18
19 xml_config = self._download_webpage(xml_link, title,
20 'Downloading XML config')
21 info = re.search(r'<format\.json>(.*?)</format\.json>',
22 xml_config, re.MULTILINE|re.DOTALL).group(1)
23 info = json.loads(info)['versions'][0]
24
25 video_url = 'http://video720.jeuxvideo.com/' + info['file']
26
27 track_info = {'id':id,
28 'title' : title,
29 'ext' : 'mp4',
30 'url' : video_url
31 }
32
33 return [track_info]