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