4 from .theplatform
import ThePlatformBaseIE
17 class MediasetIE(ThePlatformBaseIE
):
23 (?:(?:www|static3)\.)?mediasetplay\.mediaset\.it/
25 (?:video|on-demand|movie)/(?:[^/]+/)+[^/]+_|
26 player/index\.html\?.*?\bprogramGuid=
28 )(?P<id>[0-9A-Z]{16,})
32 'url': 'https://www.mediasetplay.mediaset.it/video/mrwronglezionidamore/episodio-1_F310575103000102',
33 'md5': 'a7e75c6384871f322adb781d3bd72c26',
35 'id': 'F310575103000102',
37 'title': 'Episodio 1',
38 'description': 'md5:e8017b7d7194e9bfb75299c2b8d81e02',
39 'thumbnail': r
're:^https?://.*\.jpg$',
41 'upload_date': '20210530',
42 'series': 'Mr Wrong - Lezioni d\'amore',
43 'timestamp': 1622413946,
44 'uploader': 'Canale 5',
47 'episode': 'Episode 1',
50 'chapters': [{'start_time': 0.0, 'end_time': 439.88}
, {'start_time': 439.88, 'end_time': 1685.84}
, {'start_time': 1685.84, 'end_time': 2682.0}
],
53 'url': 'https://www.mediasetplay.mediaset.it/video/matrix/puntata-del-25-maggio_F309013801000501',
54 'md5': '1276f966ac423d16ba255ce867de073e',
56 'id': 'F309013801000501',
58 'title': 'Puntata del 25 maggio',
59 'description': 'md5:ee2e456e3eb1dba5e814596655bb5296',
60 'thumbnail': r
're:^https?://.*\.jpg$',
62 'upload_date': '20200903',
64 'timestamp': 1599172492,
65 'uploader': 'Canale 5',
68 'episode': 'Episode 5',
71 'chapters': [{'start_time': 0.0, 'end_time': 3409.08}
, {'start_time': 3409.08, 'end_time': 6565.008}
],
74 'url': 'https://www.mediasetplay.mediaset.it/video/cameracafe5/episodio-69-pezzo-di-luna_F303843101017801',
75 'md5': 'd1650ac9ff944f185556126a736df148',
77 'id': 'F303843101017801',
79 'title': 'Episodio 69 - Pezzo di luna',
80 'description': 'md5:7c32c8ec4118b72588b9412f11353f73',
81 'thumbnail': r
're:^https?://.*\.jpg$',
83 'upload_date': '20200902',
84 'series': 'Camera Café 5',
85 'timestamp': 1599064700,
86 'uploader': 'Italia 1',
89 'episode': 'Episode 178',
91 'episode_number': 178,
92 'chapters': [{'start_time': 0.0, 'end_time': 261.88}
, {'start_time': 261.88, 'end_time': 263.008}
],
95 'url': 'https://www.mediasetplay.mediaset.it/video/cameracafe5/episodio-51-tu-chi-sei_F303843107000601',
96 'md5': '567e9ad375b7a27a0e370650f572a1e3',
98 'id': 'F303843107000601',
100 'title': 'Episodio 51 - Tu chi sei?',
101 'description': 'md5:42ef006e56824cc31787a547590923f4',
102 'thumbnail': r
're:^https?://.*\.jpg$',
104 'upload_date': '20200902',
105 'series': 'Camera Café 5',
106 'timestamp': 1599069817,
107 'uploader': 'Italia 1',
109 'season': 'Season 5',
110 'episode': 'Episode 6',
113 'chapters': [{'start_time': 0.0, 'end_time': 358.68}
, {'start_time': 358.68, 'end_time': 367.021}
],
117 'url': 'https://www.mediasetplay.mediaset.it/movie/selvaggi/selvaggi_F006474501000101',
118 'md5': '720440187a2ae26af8148eb9e6b901ed',
120 'id': 'F006474501000101',
123 'description': 'md5:cfdedbbfdd12d4d0e5dcf1fa1b75284f',
124 'thumbnail': r
're:^https?://.*\.jpg$',
126 'upload_date': '20210729',
127 'timestamp': 1627594716,
128 'uploader': 'Cine34',
130 'chapters': [{'start_time': 0.0, 'end_time': 1938.56}
, {'start_time': 1938.56, 'end_time': 5233.01}
],
134 'url': 'https://www.mediasetplay.mediaset.it/video/gogglebox/un-grande-classico-della-commedia-sexy_FAFU000000661680',
135 'only_matching': True,
138 'url': 'https://static3.mediasetplay.mediaset.it/player/index.html?appKey=5ad3966b1de1c4000d5cec48&programGuid=FAFU000000665924&id=665924',
139 'only_matching': True,
141 # iframe twitter (from http://www.wittytv.it/se-prima-mi-fidavo-zero/)
142 'url': 'https://static3.mediasetplay.mediaset.it/player/index.html?appKey=5ad3966b1de1c4000d5cec48&programGuid=FAFU000000665104&id=665104',
143 'only_matching': True,
145 'url': 'mediaset:FAFU000000665924',
146 'only_matching': True,
148 'url': 'https://www.mediasetplay.mediaset.it/video/mediasethaacuoreilfuturo/palmieri-alicudi-lisola-dei-tre-bambini-felici--un-decreto-per-alicudi-e-tutte-le-microscuole_FD00000000102295',
149 'only_matching': True,
151 'url': 'https://www.mediasetplay.mediaset.it/video/cherryseason/anticipazioni-degli-episodi-del-23-ottobre_F306837101005C02',
152 'only_matching': True,
154 'url': 'https://www.mediasetplay.mediaset.it/video/tg5/ambiente-onda-umana-per-salvare-il-pianeta_F309453601079D01',
155 'only_matching': True,
157 'url': 'https://www.mediasetplay.mediaset.it/video/grandefratellovip/benedetta-una-doccia-gelata_F309344401044C135',
158 'only_matching': True,
160 'url': 'https://www.mediasetplay.mediaset.it/movie/herculeslaleggendahainizio/hercules-la-leggenda-ha-inizio_F305927501000102',
161 'only_matching': True,
165 def _extract_urls(ie
, webpage
):
169 def _program_guid(qs
):
170 return qs
.get('programGuid', [None])[0]
173 for mobj
in re
.finditer(
174 r
'<iframe\b[^>]+\bsrc=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?video\
.mediaset\
.it
/player
/playerIFrame(?
:Twitter
)?\
.shtml
.*?
)\
1',
176 embed_url = mobj.group('url
')
177 embed_qs = _qs(embed_url)
178 program_guid = _program_guid(embed_qs)
180 entries.append(embed_url)
182 video_id = embed_qs.get('id', [None])[0]
185 urlh = ie._request_webpage(
186 embed_url, video_id, note='Following embed URL redirect
')
187 embed_url = urlh.geturl()
188 program_guid = _program_guid(_qs(embed_url))
190 entries.append(embed_url)
193 def _parse_smil_formats(self, smil, smil_url, video_id, namespace=None, f4m_params=None, transform_rtmp_url=None):
194 for video in smil.findall(self._xpath_ns('.//video
', namespace)):
195 video.attrib['src
'] = re.sub(r'(https?
://vod05
)t(-mediaset
-it\
.akamaized\
.net
/.+?
.mpd
)\?.+', r'\
1\
2', video.attrib['src
'])
196 return super(MediasetIE, self)._parse_smil_formats(smil, smil_url, video_id, namespace, f4m_params, transform_rtmp_url)
198 def _check_drm_formats(self, tp_formats, video_id):
199 has_nondrm, drm_manifest = False, ''
201 if '_sampleaes
/' in (f.get('manifest_url
') or ''):
202 drm_manifest = drm_manifest or f['manifest_url
']
204 if not f.get('has_drm
') and f.get('manifest_url
'):
207 nodrm_manifest = re.sub(r'_sampleaes
/(\w
+)_fp_
', r'/\
1_no
_', drm_manifest)
208 if has_nondrm or nodrm_manifest == drm_manifest:
211 tp_formats.extend(self._extract_m3u8_formats(
212 nodrm_manifest, video_id, m3u8_id='hls
', fatal=False) or [])
214 def _real_extract(self, url):
215 guid = self._match_id(url)
216 tp_path = 'PR1GhC
/media
/guid
/2702976343/' + guid
217 info = self._extract_theplatform_metadata(tp_path, guid)
221 first_e = geo_e = None
222 asset_type = 'geoNo
:HD
,browser
,geoIT|geoNo
:HD
,geoIT|geoNo
:SD
,browser
,geoIT|geoNo
:SD
,geoIT|geoNo|HD|SD
'
223 # TODO: fixup ISM+none manifest URLs
224 for f in ('MPEG4
', 'M3U
'):
226 tp_formats, tp_subtitles = self._extract_theplatform_smil(
227 update_url_query('http
://link
.theplatform
.%s/s
/%s' % (self._TP_TLD, tp_path), {
230 'assetTypes
': asset_type,
231 }), guid, 'Downloading
%s SMIL data
' % (f.split('+')[0]))
232 except ExtractorError as e:
233 if not geo_e and isinstance(e, GeoRestrictedError):
238 self._check_drm_formats(tp_formats, guid)
239 formats.extend(tp_formats)
240 subtitles = self._merge_subtitles(subtitles, tp_subtitles)
242 # check for errors and report them
243 if (first_e or geo_e) and not formats:
244 raise geo_e or first_e
246 self._sort_formats(formats)
248 feed_data = self._download_json(
249 'https
://feed
.entertainment
.tv
.theplatform
.eu
/f
/PR1GhC
/mediaset
-prod
-all
-programs
-v2
/guid
/-/' + guid,
252 publish_info = feed_data.get('mediasetprogram$publishInfo
') or {}
253 thumbnails = feed_data.get('thumbnails
') or {}
255 for key, value in thumbnails.items():
256 if key.startswith('image_keyframe_poster
-'):
257 thumbnail = value.get('url
')
261 'description
': info.get('description
') or feed_data.get('description
') or feed_data.get('longDescription
'),
262 'uploader
': publish_info.get('description
'),
263 'uploader_id
': publish_info.get('channel
'),
264 'view_count
': int_or_none(feed_data.get('mediasetprogram$numberOfViews
')),
265 'thumbnail
': thumbnail,
268 if feed_data.get('programType
') == 'episode
':
270 'episode_number
': int_or_none(
271 feed_data.get('tvSeasonEpisodeNumber
')),
272 'season_number
': int_or_none(
273 feed_data.get('tvSeasonNumber
')),
274 'series
': feed_data.get('mediasetprogram$brandTitle
'),
280 'subtitles
': subtitles,
285 class MediasetShowIE(MediasetIE):
286 _VALID_URL = r'''(?x)
289 (?:(?:www|static3)\.)?mediasetplay\.mediaset\.it/
291 (?:fiction|programmi-tv|serie-tv|kids)/(?:.+?/)?
292 (?:[a-z-]+)_SE(?P<id>\d{12})
293 (?:,ST(?P<st>\d{12}))?
294 (?:,sb(?P<sb>\d{9}))?$
299 # TV Show webpage (general webpage)
300 'url
': 'https
://www
.mediasetplay
.mediaset
.it
/programmi
-tv
/leiene
/leiene_SE000000000061
',
302 'id': '000000000061',
305 'playlist_mincount
': 7,
307 # TV Show webpage (specific season)
308 'url
': 'https
://www
.mediasetplay
.mediaset
.it
/programmi
-tv
/leiene
/leiene_SE000000000061
,ST000000002763
',
310 'id': '000000002763',
313 'playlist_mincount
': 7,
315 # TV Show specific playlist (with multiple pages)
316 'url
': 'https
://www
.mediasetplay
.mediaset
.it
/programmi
-tv
/leiene
/iservizi_SE000000000061
,ST000000002763
,sb100013375
',
319 'title
': 'I servizi
',
321 'playlist_mincount
': 50,
324 _BY_SUBBRAND = 'https
://feed
.entertainment
.tv
.theplatform
.eu
/f
/PR1GhC
/mediaset
-prod
-all
-programs
-v2?byCustomValue
={subBrandId}{%s}
&sort
=:publishInfo_lastPublished|desc
,tvSeasonEpisodeNumber|desc
&range=%d-%d'
327 def _fetch_page(self, sb, page):
328 lower_limit = page * self._PAGE_SIZE + 1
329 upper_limit = lower_limit + self._PAGE_SIZE - 1
330 content = self._download_json(
331 self._BY_SUBBRAND % (sb, lower_limit, upper_limit), sb)
332 for entry in content.get('entries
') or []:
333 yield self.url_result(
334 'mediaset
:' + entry['guid
'],
335 playlist_title=entry['mediasetprogram$subBrandDescription
'])
337 def _real_extract(self, url):
338 playlist_id, st, sb = self._match_valid_url(url).group('id', 'st
', 'sb
')
340 page = self._download_webpage(url, st or playlist_id)
341 entries = [self.url_result(urljoin('https
://www
.mediasetplay
.mediaset
.it
', url))
342 for url in re.findall(r'href
="([^<>=]+SE\d{12},ST\d{12},sb\d{9})">[^
<]+<', page)]
343 title = (self._html_search_regex(r'(?s
)<h1
[^
>]*>(.+?
)</h1
>', page, 'title
', default=None)
344 or self._og_search_title(page))
345 return self.playlist_result(entries, st or playlist_id, title)
347 entries = OnDemandPagedList(
348 functools.partial(self._fetch_page, sb),
350 title = try_get(entries, lambda x: x[0]['playlist_title
'])
352 return self.playlist_result(entries, sb, title)