4 from .theplatform
import ThePlatformBaseIE
16 class MediasetIE(ThePlatformBaseIE
):
18 _GUID_RE
= r
'F[0-9A-Z]{15}'
19 _VALID_URL
= rf
'''(?x)
23 (?:\w+\.)+mediaset\.it/
25 (?:video|on-demand|movie)/(?:[^/]+/)+[^/]+_|
26 player/(?:v\d+/)?index\.html\?\S*?\bprogramGuid=
32 rf
'<iframe[^>]+src=[\'"](?P<url>(?:https?:)?//(?:\w+\.)+mediaset\.it/player/(?:v\d+/)?index\.html\?\S*?programGuid={_GUID_RE})[\'"&]'
36 'url': 'https://mediasetinfinity.mediaset.it/video/mrwronglezionidamore/episodio-1_F310575103000102',
37 'md5': 'a7e75c6384871f322adb781d3bd72c26',
39 'id': 'F310575103000102',
41 'title': 'Episodio 1',
42 'description': 'md5:e8017b7d7194e9bfb75299c2b8d81e02',
43 'thumbnail': r
're:^https?://.*\.jpg$',
45 'upload_date': '20210530',
46 'series': 'Mr Wrong - Lezioni d\'amore',
47 'timestamp': 1622413946,
48 'uploader': 'Canale 5',
51 'episode': 'Episode 1',
54 '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}
],
57 'url': 'https://mediasetinfinity.mediaset.it/video/matrix/puntata-del-25-maggio_F309013801000501',
58 'md5': '1276f966ac423d16ba255ce867de073e',
60 'id': 'F309013801000501',
62 'title': 'Puntata del 25 maggio',
63 'description': 'md5:ee2e456e3eb1dba5e814596655bb5296',
64 'thumbnail': r
're:^https?://.*\.jpg$',
66 'upload_date': '20200903',
68 'timestamp': 1599172492,
69 'uploader': 'Canale 5',
72 'episode': 'Episode 5',
75 'chapters': [{'start_time': 0.0, 'end_time': 3409.08}
, {'start_time': 3409.08, 'end_time': 6565.008}
],
79 'url': 'https://mediasetinfinity.mediaset.it/movie/selvaggi/selvaggi_F006474501000101',
81 'id': 'F006474501000101',
84 'description': 'md5:cfdedbbfdd12d4d0e5dcf1fa1b75284f',
85 'thumbnail': r
're:^https?://.*\.jpg$',
87 'upload_date': '20210729',
88 'timestamp': 1627594716,
91 'chapters': [{'start_time': 0.0, 'end_time': 1938.56}
, {'start_time': 1938.56, 'end_time': 5233.01}
],
94 'ignore_no_formats_error': True,
96 'expected_warnings': [
97 'None of the available releases match the specified AssetType, ProtectionScheme, and/or Format preferences',
98 'Content behind paywall and DRM',
103 'url': 'https://www.mediasetplay.mediaset.it/video/mrwronglezionidamore/episodio-1_F310575103000102',
104 'only_matching': True,
107 'url': 'https://static3.mediasetplay.mediaset.it/player/index.html?appKey=5ad3966b1de1c4000d5cec48&programGuid=FAFU000000665924&id=665924',
108 'only_matching': True,
110 'url': 'mediaset:FAFU000000665924',
111 'only_matching': True,
115 'url': 'http://www.tgcom24.mediaset.it/politica/serracchiani-voglio-vivere-in-una-societa-aperta-reazioni-sproporzionate-_3071354-201702a.shtml',
117 'id': 'FD00000000004929',
119 'title': 'Serracchiani: "Voglio vivere in una società aperta, con tutela del patto di fiducia"',
121 'thumbnail': r
're:^https?://.*\.jpg$',
122 'uploader': 'Mediaset Play',
124 'upload_date': '20201005',
125 'timestamp': 1601866168,
129 'skip_download': True,
133 'url': 'https://www.wittytv.it/mauriziocostanzoshow/ultima-puntata-venerdi-25-novembre/',
135 'id': 'F312172801000801',
137 'title': 'Ultima puntata - Venerdì 25 novembre',
138 'description': 'Una serata all\'insegna della musica e del buonumore ma non priva di spunti di riflessione',
140 'thumbnail': r
're:^https?://.*\.jpg$',
141 'uploader': 'Canale 5',
143 'upload_date': '20221126',
144 'timestamp': 1669428689,
146 'series': 'Maurizio Costanzo Show',
147 'season': 'Season 12',
149 'episode': 'Episode 8',
153 'skip_download': True,
157 def _parse_smil_formats_and_subtitles(
158 self
, smil
, smil_url
, video_id
, namespace
=None, f4m_params
=None, transform_rtmp_url
=None):
159 for video
in smil
.findall(self
._xpath
_ns
('.//video', namespace
)):
160 video
.attrib
['src'] = re
.sub(r
'(https?://vod05)t(-mediaset-it\.akamaized\.net/.+?.mpd)\?.+', r
'\1\2', video
.attrib
['src'])
161 return super(MediasetIE
, self
)._parse
_smil
_formats
_and
_subtitles
(
162 smil
, smil_url
, video_id
, namespace
, f4m_params
, transform_rtmp_url
)
164 def _check_drm_formats(self
, tp_formats
, video_id
):
165 has_nondrm
, drm_manifest
= False, ''
167 if '_sampleaes/' in (f
.get('manifest_url') or ''):
168 drm_manifest
= drm_manifest
or f
['manifest_url']
170 if not f
.get('has_drm') and f
.get('manifest_url'):
173 nodrm_manifest
= re
.sub(r
'_sampleaes/(\w+)_fp_', r
'/\1_no_', drm_manifest
)
174 if has_nondrm
or nodrm_manifest
== drm_manifest
:
177 tp_formats
.extend(self
._extract
_m
3u8_formats
(
178 nodrm_manifest
, video_id
, m3u8_id
='hls', fatal
=False) or [])
180 def _real_extract(self
, url
):
181 guid
= self
._match
_id
(url
)
182 tp_path
= f
'PR1GhC/media/guid/2702976343/{guid}'
183 info
= self
._extract
_theplatform
_metadata
(tp_path
, guid
)
187 first_e
= geo_e
= None
188 asset_type
= 'geoNo:HD,browser,geoIT|geoNo:HD,geoIT|geoNo:SD,browser,geoIT|geoNo:SD,geoIT|geoNo|HD|SD'
189 # TODO: fixup ISM+none manifest URLs
190 for f
in ('MPEG4', 'MPEG-DASH', 'M3U'):
192 tp_formats
, tp_subtitles
= self
._extract
_theplatform
_smil
(
193 update_url_query(f
'http://link.theplatform.{self._TP_TLD}/s/{tp_path}', {
196 'assetTypes': asset_type
,
197 }), guid
, f
'Downloading {f.split("+")[0]} SMIL data')
198 except ExtractorError
as e
:
199 if e
.orig_msg
== 'None of the available releases match the specified AssetType, ProtectionScheme, and/or Format preferences':
200 e
.orig_msg
= 'This video is DRM protected'
201 if not geo_e
and isinstance(e
, GeoRestrictedError
):
206 self
._check
_drm
_formats
(tp_formats
, guid
)
207 formats
.extend(tp_formats
)
208 subtitles
= self
._merge
_subtitles
(subtitles
, tp_subtitles
)
210 # check for errors and report them
211 if (first_e
or geo_e
) and not formats
:
212 raise geo_e
or first_e
214 feed_data
= self
._download
_json
(
215 f
'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs-v2/guid/-/{guid}',
218 publish_info
= feed_data
.get('mediasetprogram$publishInfo') or {}
219 thumbnails
= feed_data
.get('thumbnails') or {}
221 for key
, value
in thumbnails
.items():
222 if key
.startswith('image_keyframe_poster-'):
223 thumbnail
= value
.get('url')
227 'description': info
.get('description') or feed_data
.get('description') or feed_data
.get('longDescription'),
228 'uploader': publish_info
.get('description'),
229 'uploader_id': publish_info
.get('channel'),
230 'view_count': int_or_none(feed_data
.get('mediasetprogram$numberOfViews')),
231 'thumbnail': thumbnail
,
234 if feed_data
.get('programType') == 'episode':
236 'episode_number': int_or_none(
237 feed_data
.get('tvSeasonEpisodeNumber')),
238 'season_number': int_or_none(
239 feed_data
.get('tvSeasonNumber')),
240 'series': feed_data
.get('mediasetprogram$brandTitle'),
246 'subtitles': subtitles
,
251 class MediasetShowIE(MediasetIE
): # XXX: Do not subclass from concrete IE
252 _VALID_URL
= r
'''(?x)
255 (\w+\.)+mediaset\.it/
257 (?:fiction|programmi-tv|serie-tv|kids)/(?:.+?/)?
258 (?:[a-z-]+)_SE(?P<id>\d{12})
259 (?:,ST(?P<st>\d{12}))?
260 (?:,sb(?P<sb>\d{9}))?$
265 # TV Show webpage (general webpage)
266 'url': 'https://mediasetinfinity.mediaset.it/programmi-tv/leiene/leiene_SE000000000061',
268 'id': '000000000061',
269 'title': 'Le Iene 2022/2023',
271 'playlist_mincount': 6,
273 # TV Show webpage (specific season)
274 'url': 'https://mediasetinfinity.mediaset.it/programmi-tv/leiene/leiene_SE000000000061,ST000000002763',
276 'id': '000000002763',
277 'title': 'Le Iene 2021/2022',
279 'playlist_mincount': 7,
281 # TV Show specific playlist (with multiple pages)
282 'url': 'https://mediasetinfinity.mediaset.it/programmi-tv/leiene/iservizi_SE000000000061,ST000000002763,sb100013375',
285 'title': 'I servizi',
287 'playlist_mincount': 50,
290 _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'
293 def _fetch_page(self
, sb
, page
):
294 lower_limit
= page
* self
._PAGE
_SIZE
+ 1
295 upper_limit
= lower_limit
+ self
._PAGE
_SIZE
- 1
296 content
= self
._download
_json
(
297 self
._BY
_SUBBRAND
% (sb
, lower_limit
, upper_limit
), sb
)
298 for entry
in content
.get('entries') or []:
299 yield self
.url_result(
300 'mediaset:' + entry
['guid'],
301 playlist_title
=entry
['mediasetprogram$subBrandDescription'])
303 def _real_extract(self
, url
):
304 playlist_id
, st
, sb
= self
._match
_valid
_url
(url
).group('id', 'st', 'sb')
306 page
= self
._download
_webpage
(url
, st
or playlist_id
)
307 entries
= [self
.url_result(urljoin('https://mediasetinfinity.mediaset.it', url
))
308 for url
in re
.findall(r
'href="([^<>=]+SE\d{12},ST\d{12},sb\d{9})">[^<]+<', page
)]
309 title
= self
._html
_extract
_title
(page
).split('|')[0].strip()
310 return self
.playlist_result(entries
, st
or playlist_id
, title
)
312 entries
= OnDemandPagedList(
313 functools
.partial(self
._fetch
_page
, sb
),
315 title
= try_get(entries
, lambda x
: x
[0]['playlist_title'])
317 return self
.playlist_result(entries
, sb
, title
)