]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/sixplay.py
d3aba58a29a981829d0562ee56d992fc49f2f67c
[youtubedl] / youtube_dl / extractor / sixplay.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 qualities,
7 int_or_none,
8 mimetype2ext,
9 determine_ext,
10 )
11
12
13 class SixPlayIE(InfoExtractor):
14 _VALID_URL = r'(?:6play:|https?://(?:www\.)?6play\.fr/.+?-c_)(?P<id>[0-9]+)'
15 _TEST = {
16 'url': 'http://www.6play.fr/jamel-et-ses-amis-au-marrakech-du-rire-p_1316/jamel-et-ses-amis-au-marrakech-du-rire-2015-c_11495320',
17 'md5': '42310bffe4ba3982db112b9cd3467328',
18 'info_dict': {
19 'id': '11495320',
20 'ext': 'mp4',
21 'title': 'Jamel et ses amis au Marrakech du rire 2015',
22 'description': 'md5:ba2149d5c321d5201b78070ee839d872',
23 },
24 }
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 clip_data = self._download_json(
29 'https://player.m6web.fr/v2/video/config/6play-auth/FR/%s.json' % video_id,
30 video_id)
31 video_data = clip_data['videoInfo']
32
33 quality_key = qualities(['lq', 'sd', 'hq', 'hd'])
34 formats = []
35 for source in clip_data['sources']:
36 source_type, source_url = source.get('type'), source.get('src')
37 if not source_url or source_type == 'hls/primetime':
38 continue
39 ext = mimetype2ext(source_type) or determine_ext(source_url)
40 if ext == 'm3u8':
41 formats.extend(self._extract_m3u8_formats(
42 source_url, video_id, 'mp4', 'm3u8_native',
43 m3u8_id='hls', fatal=False))
44 formats.extend(self._extract_f4m_formats(
45 source_url.replace('.m3u8', '.f4m'),
46 video_id, f4m_id='hds', fatal=False))
47 elif ext == 'mp4':
48 quality = source.get('quality')
49 formats.append({
50 'url': source_url,
51 'format_id': quality,
52 'quality': quality_key(quality),
53 'ext': ext,
54 })
55 self._sort_formats(formats)
56
57 return {
58 'id': video_id,
59 'title': video_data['title'].strip(),
60 'description': video_data.get('description'),
61 'duration': int_or_none(video_data.get('duration')),
62 'series': video_data.get('titlePgm'),
63 'formats': formats,
64 }