]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/clubic.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / clubic.py
CommitLineData
478c2c61
PH
1from .common import InfoExtractor
2from ..utils import (
3 clean_html,
4 qualities,
5)
6
7
8class ClubicIE(InfoExtractor):
9751a457 9 _WORKING = False
5886b38d 10 _VALID_URL = r'https?://(?:www\.)?clubic\.com/video/(?:[^/]+/)*video.*-(?P<id>[0-9]+)\.html'
478c2c61 11
e2ff3df3 12 _TESTS = [{
478c2c61
PH
13 'url': 'http://www.clubic.com/video/clubic-week/video-clubic-week-2-0-le-fbi-se-lance-dans-la-photo-d-identite-448474.html',
14 'md5': '1592b694ba586036efac1776b0b43cd3',
15 'info_dict': {
16 'id': '448474',
17 'ext': 'mp4',
18 'title': 'Clubic Week 2.0 : le FBI se lance dans la photo d\u0092identité',
19 'description': 're:Gueule de bois chez Nokia. Le constructeur a indiqué cette.*',
ec85ded8 20 'thumbnail': r're:^http://img\.clubic\.com/.*\.jpg$',
add96eb9 21 },
e2ff3df3
S
22 }, {
23 'url': 'http://www.clubic.com/video/video-clubic-week-2-0-apple-iphone-6s-et-plus-mais-surtout-le-pencil-469792.html',
24 'only_matching': True,
25 }]
478c2c61
PH
26
27 def _real_extract(self, url):
eaf9b22f 28 video_id = self._match_id(url)
478c2c61 29
add96eb9 30 player_url = f'http://player.m6web.fr/v1/player/clubic/{video_id}.html'
478c2c61
PH
31 player_page = self._download_webpage(player_url, video_id)
32
eaf9b22f 33 config = self._parse_json(self._search_regex(
478c2c61 34 r'(?m)M6\.Player\.config\s*=\s*(\{.+?\});$', player_page,
eaf9b22f 35 'configuration'), video_id)
478c2c61
PH
36
37 video_info = config['videoInfo']
38 sources = config['sources']
39 quality_order = qualities(['sd', 'hq'])
40
41 formats = [{
42 'format_id': src['streamQuality'],
43 'url': src['src'],
44 'quality': quality_order(src['streamQuality']),
45 } for src in sources]
478c2c61
PH
46
47 return {
48 'id': video_id,
49 'title': video_info['title'],
50 'formats': formats,
51 'description': clean_html(video_info.get('description')),
52 'thumbnail': config.get('poster'),
53 }