2 from __future__
import unicode_literals
6 from .theplatform
import ThePlatformBaseIE
9 compat_urllib_parse_urlparse
,
18 class MediasetIE(ThePlatformBaseIE
):
24 (?:(?:www|static3)\.)?mediasetplay\.mediaset\.it/
26 (?:video|on-demand)/(?:[^/]+/)+[^/]+_|
27 player/index\.html\?.*?\bprogramGuid=
29 )(?P<id>[0-9A-Z]{16,})
33 'url': 'https://www.mediasetplay.mediaset.it/video/hellogoodbye/quarta-puntata_FAFU000000661824',
34 'md5': '9b75534d42c44ecef7bf1ffeacb7f85d',
36 'id': 'FAFU000000661824',
38 'title': 'Quarta puntata',
39 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
40 'thumbnail': r
're:^https?://.*\.jpg$',
42 'upload_date': '20161107',
43 'series': 'Hello Goodbye',
44 'timestamp': 1478532900,
49 'url': 'https://www.mediasetplay.mediaset.it/video/matrix/puntata-del-25-maggio_F309013801000501',
50 'md5': '288532f0ad18307705b01e581304cd7b',
52 'id': 'F309013801000501',
54 'title': 'Puntata del 25 maggio',
55 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
56 'thumbnail': r
're:^https?://.*\.jpg$',
58 'upload_date': '20180526',
60 'timestamp': 1527326245,
61 'uploader': 'Canale 5',
66 'url': 'https://www.mediasetplay.mediaset.it/video/gogglebox/un-grande-classico-della-commedia-sexy_FAFU000000661680',
67 'only_matching': True,
70 'url': 'https://static3.mediasetplay.mediaset.it/player/index.html?appKey=5ad3966b1de1c4000d5cec48&programGuid=FAFU000000665924&id=665924',
71 'only_matching': True,
73 # iframe twitter (from http://www.wittytv.it/se-prima-mi-fidavo-zero/)
74 'url': 'https://static3.mediasetplay.mediaset.it/player/index.html?appKey=5ad3966b1de1c4000d5cec48&programGuid=FAFU000000665104&id=665104',
75 'only_matching': True,
77 'url': 'mediaset:FAFU000000665924',
78 'only_matching': True,
80 'url': 'https://www.mediasetplay.mediaset.it/video/mediasethaacuoreilfuturo/palmieri-alicudi-lisola-dei-tre-bambini-felici--un-decreto-per-alicudi-e-tutte-le-microscuole_FD00000000102295',
81 'only_matching': True,
83 'url': 'https://www.mediasetplay.mediaset.it/video/cherryseason/anticipazioni-degli-episodi-del-23-ottobre_F306837101005C02',
84 'only_matching': True,
86 'url': 'https://www.mediasetplay.mediaset.it/video/tg5/ambiente-onda-umana-per-salvare-il-pianeta_F309453601079D01',
87 'only_matching': True,
89 'url': 'https://www.mediasetplay.mediaset.it/video/grandefratellovip/benedetta-una-doccia-gelata_F309344401044C135',
90 'only_matching': True,
94 def _extract_urls(ie
, webpage
):
96 return compat_parse_qs(compat_urllib_parse_urlparse(url
).query
)
98 def _program_guid(qs
):
99 return qs
.get('programGuid', [None])[0]
102 for mobj
in re
.finditer(
103 r
'<iframe\b[^>]+\bsrc=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?video\
.mediaset\
.it
/player
/playerIFrame(?
:Twitter
)?\
.shtml
.*?
)\
1',
105 embed_url = mobj.group('url
')
106 embed_qs = _qs(embed_url)
107 program_guid = _program_guid(embed_qs)
109 entries.append(embed_url)
111 video_id = embed_qs.get('id', [None])[0]
114 urlh = ie._request_webpage(
115 embed_url, video_id, note='Following embed URL redirect
')
116 embed_url = urlh.geturl()
117 program_guid = _program_guid(_qs(embed_url))
119 entries.append(embed_url)
122 def _parse_smil_formats(self, smil, smil_url, video_id, namespace=None, f4m_params=None, transform_rtmp_url=None):
123 for video in smil.findall(self._xpath_ns('.//video
', namespace)):
124 video.attrib['src
'] = re.sub(r'(https?
://vod05
)t(-mediaset
-it\
.akamaized\
.net
/.+?
.mpd
)\?.+', r'\
1\
2', video.attrib['src
'])
125 return super(MediasetIE, self)._parse_smil_formats(smil, smil_url, video_id, namespace, f4m_params, transform_rtmp_url)
127 def _real_extract(self, url):
128 guid = self._match_id(url)
129 tp_path = 'PR1GhC
/media
/guid
/2702976343/' + guid
130 info = self._extract_theplatform_metadata(tp_path, guid)
135 for asset_type in ('SD
', 'HD
'):
136 # TODO: fixup ISM+none manifest URLs
137 for f in ('MPEG4
', 'MPEG
-DASH
+none
', 'M3U
+none
'):
139 tp_formats, tp_subtitles = self._extract_theplatform_smil(
140 update_url_query('http
://link
.theplatform
.%s/s
/%s' % (self._TP_TLD, tp_path), {
143 'assetTypes
': asset_type,
144 }), guid, 'Downloading
%s %s SMIL data
' % (f.split('+')[0], asset_type))
145 except ExtractorError as e:
149 for tp_f in tp_formats:
150 tp_f['quality
'] = 1 if asset_type == 'HD
' else 0
151 formats.extend(tp_formats)
152 subtitles = self._merge_subtitles(subtitles, tp_subtitles)
153 if first_e and not formats:
155 self._sort_formats(formats)
158 for templ, repls in (('tvSeason
%sNumber
', ('', 'Episode
')), ('mediasetprogram$
%s', ('brandTitle
', 'numberOfViews
', 'publishInfo
'))):
159 fields.extend(templ % repl for repl in repls)
160 feed_data = self._download_json(
161 'https
://feed
.entertainment
.tv
.theplatform
.eu
/f
/PR1GhC
/mediaset
-prod
-all
-programs
/guid
/-/' + guid,
162 guid, fatal=False, query={'fields
': ','.join(fields)})
164 publish_info = feed_data.get('mediasetprogram$publishInfo
') or {}
166 'episode_number
': int_or_none(feed_data.get('tvSeasonEpisodeNumber
')),
167 'season_number
': int_or_none(feed_data.get('tvSeasonNumber
')),
168 'series
': feed_data.get('mediasetprogram$brandTitle
'),
169 'uploader
': publish_info.get('description
'),
170 'uploader_id
': publish_info.get('channel
'),
171 'view_count
': int_or_none(feed_data.get('mediasetprogram$numberOfViews
')),
177 'subtitles
': subtitles,