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