]>
Commit | Line | Data |
---|---|---|
12300fa4 RA |
1 | from .common import InfoExtractor |
2 | from ..compat import ( | |
12300fa4 RA |
3 | compat_parse_qs, |
4 | compat_urllib_parse_urlparse, | |
5 | ) | |
6 | from ..utils import ( | |
7 | dict_get, | |
8 | int_or_none, | |
9 | parse_duration, | |
10 | unified_timestamp, | |
11 | ) | |
12 | ||
13 | ||
14 | class SkyItPlayerIE(InfoExtractor): | |
15 | IE_NAME = 'player.sky.it' | |
16 | _VALID_URL = r'https?://player\.sky\.it/player/(?:external|social)\.html\?.*?\bid=(?P<id>\d+)' | |
17 | _GEO_BYPASS = False | |
18 | _DOMAIN = 'sky' | |
19 | _PLAYER_TMPL = 'https://player.sky.it/player/external.html?id=%s&domain=%s' | |
20 | # http://static.sky.it/static/skyplayer/conf.json | |
21 | _TOKEN_MAP = { | |
22 | 'cielo': 'Hh9O7M8ks5yi6nSROL7bKYz933rdf3GhwZlTLMgvy4Q', | |
23 | 'hotclub': 'kW020K2jq2lk2eKRJD2vWEg832ncx2EivZlTLQput2C', | |
24 | 'mtv8': 'A5Nn9GGb326CI7vP5e27d7E4PIaQjota', | |
25 | 'salesforce': 'C6D585FD1615272C98DE38235F38BD86', | |
26 | 'sitocommerciale': 'VJwfFuSGnLKnd9Phe9y96WkXgYDCguPMJ2dLhGMb2RE', | |
27 | 'sky': 'F96WlOd8yoFmLQgiqv6fNQRvHZcsWk5jDaYnDvhbiJk', | |
12300fa4 RA |
28 | 'skyarte': 'LWk29hfiU39NNdq87ePeRach3nzTSV20o0lTv2001Cd', |
29 | 'theupfront': 'PRSGmDMsg6QMGc04Obpoy7Vsbn7i2Whp', | |
30 | } | |
31 | ||
32 | def _player_url_result(self, video_id): | |
33 | return self.url_result( | |
34 | self._PLAYER_TMPL % (video_id, self._DOMAIN), | |
35 | SkyItPlayerIE.ie_key(), video_id) | |
36 | ||
37 | def _parse_video(self, video, video_id): | |
38 | title = video['title'] | |
39 | is_live = video.get('type') == 'live' | |
40 | hls_url = video.get(('streaming' if is_live else 'hls') + '_url') | |
41 | if not hls_url and video.get('geoblock' if is_live else 'geob'): | |
42 | self.raise_geo_restricted(countries=['IT']) | |
43 | ||
d715b0e4 | 44 | formats = self._extract_m3u8_formats(hls_url, video_id, 'mp4') |
12300fa4 RA |
45 | self._sort_formats(formats) |
46 | ||
47 | return { | |
48 | 'id': video_id, | |
39ca3b5c | 49 | 'title': title, |
12300fa4 RA |
50 | 'formats': formats, |
51 | 'thumbnail': dict_get(video, ('video_still', 'video_still_medium', 'thumb')), | |
52 | 'description': video.get('short_desc') or None, | |
53 | 'timestamp': unified_timestamp(video.get('create_date')), | |
54 | 'duration': int_or_none(video.get('duration_sec')) or parse_duration(video.get('duration')), | |
55 | 'is_live': is_live, | |
56 | } | |
57 | ||
58 | def _real_extract(self, url): | |
59 | video_id = self._match_id(url) | |
60 | domain = compat_parse_qs(compat_urllib_parse_urlparse( | |
61 | url).query).get('domain', [None])[0] | |
62 | token = dict_get(self._TOKEN_MAP, (domain, 'sky')) | |
63 | video = self._download_json( | |
64 | 'https://apid.sky.it/vdp/v1/getVideoData', | |
65 | video_id, query={ | |
66 | 'caller': 'sky', | |
67 | 'id': video_id, | |
68 | 'token': token | |
69 | }, headers=self.geo_verification_headers()) | |
70 | return self._parse_video(video, video_id) | |
71 | ||
72 | ||
6368e2e6 | 73 | class SkyItVideoIE(SkyItPlayerIE): # XXX: Do not subclass from concrete IE |
12300fa4 RA |
74 | IE_NAME = 'video.sky.it' |
75 | _VALID_URL = r'https?://(?:masterchef|video|xfactor)\.sky\.it(?:/[^/]+)*/video/[0-9a-z-]+-(?P<id>\d+)' | |
76 | _TESTS = [{ | |
77 | 'url': 'https://video.sky.it/news/mondo/video/uomo-ucciso-da-uno-squalo-in-australia-631227', | |
d715b0e4 | 78 | 'md5': '5b858a62d9ffe2ab77b397553024184a', |
12300fa4 RA |
79 | 'info_dict': { |
80 | 'id': '631227', | |
81 | 'ext': 'mp4', | |
82 | 'title': 'Uomo ucciso da uno squalo in Australia', | |
83 | 'timestamp': 1606036192, | |
84 | 'upload_date': '20201122', | |
d715b0e4 | 85 | 'duration': 26, |
86 | 'thumbnail': 'https://video.sky.it/captures/thumbs/631227/631227_thumb_880x494.jpg', | |
87 | }, | |
88 | 'params': {'skip_download': 'm3u8'}, | |
12300fa4 RA |
89 | }, { |
90 | 'url': 'https://xfactor.sky.it/video/x-factor-2020-replay-audizioni-1-615820', | |
91 | 'only_matching': True, | |
92 | }, { | |
93 | 'url': 'https://masterchef.sky.it/video/masterchef-9-cosa-e-successo-nella-prima-puntata-562831', | |
94 | 'only_matching': True, | |
95 | }] | |
96 | ||
97 | def _real_extract(self, url): | |
98 | video_id = self._match_id(url) | |
99 | return self._player_url_result(video_id) | |
100 | ||
101 | ||
6368e2e6 | 102 | class SkyItVideoLiveIE(SkyItPlayerIE): # XXX: Do not subclass from concrete IE |
12300fa4 RA |
103 | IE_NAME = 'video.sky.it:live' |
104 | _VALID_URL = r'https?://video\.sky\.it/diretta/(?P<id>[^/?&#]+)' | |
105 | _TEST = { | |
106 | 'url': 'https://video.sky.it/diretta/tg24', | |
107 | 'info_dict': { | |
108 | 'id': '1', | |
109 | 'ext': 'mp4', | |
110 | 'title': r're:Diretta TG24 \d{4}-\d{2}-\d{2} \d{2}:\d{2}', | |
d715b0e4 | 111 | 'description': r're:(?:Clicca play e )?[Gg]uarda la diretta streaming di SkyTg24, segui con Sky tutti gli appuntamenti e gli speciali di Tg24\.', |
112 | 'live_status': 'is_live', | |
12300fa4 RA |
113 | }, |
114 | 'params': { | |
115 | # m3u8 download | |
116 | 'skip_download': True, | |
117 | }, | |
118 | } | |
119 | ||
120 | def _real_extract(self, url): | |
121 | display_id = self._match_id(url) | |
122 | webpage = self._download_webpage(url, display_id) | |
135dfa2c | 123 | asset_id = str(self._search_nextjs_data(webpage, display_id)['props']['initialState']['livePage']['content']['asset_id']) |
12300fa4 RA |
124 | livestream = self._download_json( |
125 | 'https://apid.sky.it/vdp/v1/getLivestream', | |
126 | asset_id, query={'id': asset_id}) | |
127 | return self._parse_video(livestream, asset_id) | |
128 | ||
129 | ||
6368e2e6 | 130 | class SkyItIE(SkyItPlayerIE): # XXX: Do not subclass from concrete IE |
12300fa4 RA |
131 | IE_NAME = 'sky.it' |
132 | _VALID_URL = r'https?://(?:sport|tg24)\.sky\.it(?:/[^/]+)*/\d{4}/\d{2}/\d{2}/(?P<id>[^/?&#]+)' | |
133 | _TESTS = [{ | |
d715b0e4 | 134 | 'url': 'https://sport.sky.it/calcio/serie-a/2022/11/03/brozovic-inter-news', |
12300fa4 | 135 | 'info_dict': { |
d715b0e4 | 136 | 'id': '789222', |
12300fa4 | 137 | 'ext': 'mp4', |
d715b0e4 | 138 | 'title': 'Brozovic con il gruppo: verso convocazione per Juve-Inter', |
139 | 'upload_date': '20221103', | |
140 | 'timestamp': 1667484130, | |
141 | 'duration': 22, | |
142 | 'thumbnail': 'https://videoplatform.sky.it/still/2022/11/03/1667480526353_brozovic_videostill_1.jpg', | |
12300fa4 | 143 | }, |
d715b0e4 | 144 | 'params': {'skip_download': 'm3u8'}, |
12300fa4 RA |
145 | }, { |
146 | 'url': 'https://tg24.sky.it/mondo/2020/11/22/australia-squalo-uccide-uomo', | |
147 | 'md5': 'fe5c91e59a84a3437eaa0bca6e134ccd', | |
148 | 'info_dict': { | |
149 | 'id': '631227', | |
150 | 'ext': 'mp4', | |
151 | 'title': 'Uomo ucciso da uno squalo in Australia', | |
152 | 'timestamp': 1606036192, | |
153 | 'upload_date': '20201122', | |
d715b0e4 | 154 | 'duration': 26, |
155 | 'thumbnail': 'https://video.sky.it/captures/thumbs/631227/631227_thumb_880x494.jpg', | |
12300fa4 | 156 | }, |
d715b0e4 | 157 | 'params': {'skip_download': 'm3u8'}, |
12300fa4 RA |
158 | }] |
159 | _VIDEO_ID_REGEX = r'data-videoid="(\d+)"' | |
160 | ||
161 | def _real_extract(self, url): | |
162 | display_id = self._match_id(url) | |
163 | webpage = self._download_webpage(url, display_id) | |
164 | video_id = self._search_regex( | |
165 | self._VIDEO_ID_REGEX, webpage, 'video id') | |
166 | return self._player_url_result(video_id) | |
167 | ||
168 | ||
6368e2e6 | 169 | class SkyItArteIE(SkyItIE): # XXX: Do not subclass from concrete IE |
12300fa4 RA |
170 | IE_NAME = 'arte.sky.it' |
171 | _VALID_URL = r'https?://arte\.sky\.it/video/(?P<id>[^/?&#]+)' | |
172 | _TESTS = [{ | |
d715b0e4 | 173 | 'url': 'https://arte.sky.it/video/oliviero-toscani-torino-galleria-mazzoleni-788962', |
12300fa4 RA |
174 | 'md5': '515aee97b87d7a018b6c80727d3e7e17', |
175 | 'info_dict': { | |
d715b0e4 | 176 | 'id': '788962', |
12300fa4 | 177 | 'ext': 'mp4', |
d715b0e4 | 178 | 'title': 'La fotografia di Oliviero Toscani conquista Torino', |
179 | 'upload_date': '20221102', | |
180 | 'timestamp': 1667399996, | |
181 | 'duration': 12, | |
182 | 'thumbnail': 'https://videoplatform.sky.it/still/2022/11/02/1667396388552_oliviero-toscani-torino-galleria-mazzoleni_videostill_1.jpg', | |
183 | }, | |
184 | 'params': {'skip_download': 'm3u8'}, | |
12300fa4 RA |
185 | }] |
186 | _DOMAIN = 'skyarte' | |
d715b0e4 | 187 | _VIDEO_ID_REGEX = r'"embedUrl"\s*:\s*"(?:https:)?//player\.sky\.it/player/external\.html\?[^"]*\bid=(\d+)' |
12300fa4 RA |
188 | |
189 | ||
6368e2e6 | 190 | class CieloTVItIE(SkyItIE): # XXX: Do not subclass from concrete IE |
12300fa4 RA |
191 | IE_NAME = 'cielotv.it' |
192 | _VALID_URL = r'https?://(?:www\.)?cielotv\.it/video/(?P<id>[^.]+)\.html' | |
193 | _TESTS = [{ | |
194 | 'url': 'https://www.cielotv.it/video/Il-lunedi-e-sempre-un-dramma.html', | |
195 | 'md5': 'c4deed77552ba901c2a0d9258320304b', | |
196 | 'info_dict': { | |
197 | 'id': '499240', | |
198 | 'ext': 'mp4', | |
199 | 'title': 'Il lunedì è sempre un dramma', | |
200 | 'upload_date': '20190329', | |
201 | 'timestamp': 1553862178, | |
d715b0e4 | 202 | 'duration': 30, |
203 | 'thumbnail': 'https://videoplatform.sky.it/still/2019/03/29/1553858575610_lunedi_dramma_mant_videostill_1.jpg', | |
204 | }, | |
205 | 'params': {'skip_download': 'm3u8'}, | |
12300fa4 RA |
206 | }] |
207 | _DOMAIN = 'cielo' | |
208 | _VIDEO_ID_REGEX = r'videoId\s*=\s*"(\d+)"' | |
209 | ||
210 | ||
6368e2e6 | 211 | class TV8ItIE(SkyItVideoIE): # XXX: Do not subclass from concrete IE |
12300fa4 | 212 | IE_NAME = 'tv8.it' |
d715b0e4 | 213 | _VALID_URL = r'https?://(?:www\.)?tv8\.it/(?:show)?video/[0-9a-z-]+-(?P<id>\d+)' |
12300fa4 | 214 | _TESTS = [{ |
d715b0e4 | 215 | 'url': 'https://www.tv8.it/video/ogni-mattina-ucciso-asino-di-andrea-lo-cicero-630529', |
12300fa4 RA |
216 | 'md5': '9ab906a3f75ea342ed928442f9dabd21', |
217 | 'info_dict': { | |
218 | 'id': '630529', | |
219 | 'ext': 'mp4', | |
220 | 'title': 'Ogni mattina - Ucciso asino di Andrea Lo Cicero', | |
221 | 'timestamp': 1605721374, | |
222 | 'upload_date': '20201118', | |
d715b0e4 | 223 | 'duration': 114, |
224 | 'thumbnail': 'https://videoplatform.sky.it/still/2020/11/18/1605717753954_ogni-mattina-ucciso-asino-di-andrea-lo-cicero_videostill_1.jpg', | |
225 | }, | |
226 | 'params': {'skip_download': 'm3u8'}, | |
12300fa4 RA |
227 | }] |
228 | _DOMAIN = 'mtv8' |