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