]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/clubic.py
debian/control: Mark package compliant with Policy 4.3.0 (no changes needed).
[youtubedl] / youtube_dl / extractor / clubic.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 clean_html,
7 qualities,
8 )
9
10
11 class ClubicIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?clubic\.com/video/(?:[^/]+/)*video.*-(?P<id>[0-9]+)\.html'
13
14 _TESTS = [{
15 'url': 'http://www.clubic.com/video/clubic-week/video-clubic-week-2-0-le-fbi-se-lance-dans-la-photo-d-identite-448474.html',
16 'md5': '1592b694ba586036efac1776b0b43cd3',
17 'info_dict': {
18 'id': '448474',
19 'ext': 'mp4',
20 'title': 'Clubic Week 2.0 : le FBI se lance dans la photo d\u0092identité',
21 'description': 're:Gueule de bois chez Nokia. Le constructeur a indiqué cette.*',
22 'thumbnail': r're:^http://img\.clubic\.com/.*\.jpg$',
23 }
24 }, {
25 'url': 'http://www.clubic.com/video/video-clubic-week-2-0-apple-iphone-6s-et-plus-mais-surtout-le-pencil-469792.html',
26 'only_matching': True,
27 }]
28
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31
32 player_url = 'http://player.m6web.fr/v1/player/clubic/%s.html' % video_id
33 player_page = self._download_webpage(player_url, video_id)
34
35 config = self._parse_json(self._search_regex(
36 r'(?m)M6\.Player\.config\s*=\s*(\{.+?\});$', player_page,
37 'configuration'), video_id)
38
39 video_info = config['videoInfo']
40 sources = config['sources']
41 quality_order = qualities(['sd', 'hq'])
42
43 formats = [{
44 'format_id': src['streamQuality'],
45 'url': src['src'],
46 'quality': quality_order(src['streamQuality']),
47 } for src in sources]
48 self._sort_formats(formats)
49
50 return {
51 'id': video_id,
52 'title': video_info['title'],
53 'formats': formats,
54 'description': clean_html(video_info.get('description')),
55 'thumbnail': config.get('poster'),
56 }