]>
Commit | Line | Data |
---|---|---|
93ad6c6b | 1 | from .common import InfoExtractor |
4bf18702 | 2 | from ..compat import ( |
4bf18702 | 3 | compat_str, |
4bf18702 | 4 | ) |
93ad6c6b | 5 | from ..utils import ( |
ab49d7a9 | 6 | determine_ext, |
b9c9cb5f | 7 | int_or_none, |
4dfbf869 | 8 | parse_qs, |
b9c9cb5f S |
9 | try_get, |
10 | qualities, | |
93ad6c6b RA |
11 | ) |
12 | ||
13 | ||
14 | class SixPlayIE(InfoExtractor): | |
c8b8fb0a | 15 | IE_NAME = '6play' |
7c24a58b | 16 | _VALID_URL = r'(?:6play:|https?://(?:www\.)?(?P<domain>6play\.fr|rtlplay\.be|play\.rtl\.hr|rtlmost\.hu)/.+?-c_)(?P<id>[0-9]+)' |
18825117 RA |
17 | _TESTS = [{ |
18 | 'url': 'https://www.6play.fr/minute-par-minute-p_9533/le-but-qui-a-marque-lhistoire-du-football-francais-c_12041051', | |
19 | 'md5': '31fcd112637baa0c2ab92c4fcd8baf27', | |
93ad6c6b | 20 | 'info_dict': { |
18825117 | 21 | 'id': '12041051', |
93ad6c6b | 22 | 'ext': 'mp4', |
18825117 RA |
23 | 'title': 'Le but qui a marqué l\'histoire du football français !', |
24 | 'description': 'md5:b59e7e841d646ef1eb42a7868eb6a851', | |
b9c9cb5f | 25 | }, |
18825117 RA |
26 | }, { |
27 | 'url': 'https://www.rtlplay.be/rtl-info-13h-p_8551/les-titres-du-rtlinfo-13h-c_12045869', | |
28 | 'only_matching': True, | |
28f96cf4 | 29 | }, { |
30 | 'url': 'https://play.rtl.hr/pj-masks-p_9455/epizoda-34-sezona-1-catboyevo-cudo-na-dva-kotaca-c_11984989', | |
31 | 'only_matching': True, | |
7c24a58b RA |
32 | }, { |
33 | 'url': 'https://www.rtlmost.hu/megtorve-p_14167/megtorve-6-resz-c_12397787', | |
34 | 'only_matching': True, | |
18825117 | 35 | }] |
93ad6c6b RA |
36 | |
37 | def _real_extract(self, url): | |
5ad28e7f | 38 | domain, video_id = self._match_valid_url(url).groups() |
18825117 RA |
39 | service, consumer_name = { |
40 | '6play.fr': ('6play', 'm6web'), | |
41 | 'rtlplay.be': ('rtlbe_rtl_play', 'rtlbe'), | |
28f96cf4 | 42 | 'play.rtl.hr': ('rtlhr_rtl_play', 'rtlhr'), |
7c24a58b | 43 | 'rtlmost.hu': ('rtlhu_rtl_most', 'rtlhu'), |
18825117 | 44 | }.get(domain, ('6play', 'm6web')) |
b9c9cb5f S |
45 | |
46 | data = self._download_json( | |
18825117 RA |
47 | 'https://pc.middleware.6play.fr/6play/v2/platforms/m6group_web/services/%s/videos/clip_%s' % (service, video_id), |
48 | video_id, headers={ | |
49 | 'x-customer-name': consumer_name | |
50 | }, query={ | |
b9c9cb5f S |
51 | 'csa': 5, |
52 | 'with': 'clips', | |
53 | }) | |
54 | ||
55 | clip_data = data['clips'][0] | |
56 | title = clip_data['title'] | |
93ad6c6b | 57 | |
c8b8fb0a | 58 | urls = [] |
0c2ac64b | 59 | quality_key = qualities(['lq', 'sd', 'hq', 'hd']) |
93ad6c6b | 60 | formats = [] |
ff873b57 | 61 | subtitles = {} |
c5b02efe RA |
62 | assets = clip_data.get('assets') or [] |
63 | for asset in assets: | |
b9c9cb5f | 64 | asset_url = asset.get('full_physical_path') |
c8b8fb0a | 65 | protocol = asset.get('protocol') |
3545d38b | 66 | if not asset_url or ((protocol == 'primetime' or asset.get('type') == 'usp_hlsfp_h264') and not ('_drmnp.ism/' in asset_url or '_unpnp.ism/' in asset_url)) or asset_url in urls: |
93ad6c6b | 67 | continue |
c8b8fb0a | 68 | urls.append(asset_url) |
b9c9cb5f S |
69 | container = asset.get('video_container') |
70 | ext = determine_ext(asset_url) | |
ff873b57 S |
71 | if protocol == 'http_subtitle' or ext == 'vtt': |
72 | subtitles.setdefault('fr', []).append({'url': asset_url}) | |
73 | continue | |
b9c9cb5f | 74 | if container == 'm3u8' or ext == 'm3u8': |
18825117 | 75 | if protocol == 'usp': |
4dfbf869 | 76 | if parse_qs(asset_url).get('token', [None])[0]: |
e12b4b8b RA |
77 | urlh = self._request_webpage( |
78 | asset_url, video_id, fatal=False, | |
79 | headers=self.geo_verification_headers()) | |
18825117 RA |
80 | if not urlh: |
81 | continue | |
82 | asset_url = urlh.geturl() | |
2309d6bf | 83 | asset_url = asset_url.replace('_drmnp.ism/', '_unpnp.ism/') |
2e1280ed RA |
84 | for i in range(3, 0, -1): |
85 | asset_url = asset_url = asset_url.replace('_sd1/', '_sd%d/' % i) | |
86 | m3u8_formats = self._extract_m3u8_formats( | |
87 | asset_url, video_id, 'mp4', 'm3u8_native', | |
88 | m3u8_id='hls', fatal=False) | |
89 | formats.extend(m3u8_formats) | |
90 | formats.extend(self._extract_mpd_formats( | |
91 | asset_url.replace('.m3u8', '.mpd'), | |
92 | video_id, mpd_id='dash', fatal=False)) | |
93 | if m3u8_formats: | |
94 | break | |
c8b8fb0a RA |
95 | else: |
96 | formats.extend(self._extract_m3u8_formats( | |
97 | asset_url, video_id, 'mp4', 'm3u8_native', | |
98 | m3u8_id='hls', fatal=False)) | |
b9c9cb5f S |
99 | elif container == 'mp4' or ext == 'mp4': |
100 | quality = asset.get('video_quality') | |
93ad6c6b | 101 | formats.append({ |
b9c9cb5f | 102 | 'url': asset_url, |
93ad6c6b | 103 | 'format_id': quality, |
0c2ac64b | 104 | 'quality': quality_key(quality), |
ab49d7a9 | 105 | 'ext': ext, |
93ad6c6b | 106 | }) |
93ad6c6b | 107 | |
b9c9cb5f S |
108 | def get(getter): |
109 | for src in (data, clip_data): | |
110 | v = try_get(src, getter, compat_str) | |
111 | if v: | |
112 | return v | |
113 | ||
93ad6c6b RA |
114 | return { |
115 | 'id': video_id, | |
b9c9cb5f S |
116 | 'title': title, |
117 | 'description': get(lambda x: x['description']), | |
118 | 'duration': int_or_none(clip_data.get('duration')), | |
119 | 'series': get(lambda x: x['program']['title']), | |
93ad6c6b | 120 | 'formats': formats, |
ff873b57 | 121 | 'subtitles': subtitles, |
93ad6c6b | 122 | } |