2 from __future__ import unicode_literals
6 from .theplatform import ThePlatformBaseIE
14 class MediasetIE(ThePlatformBaseIE):
20 (?:(?:www|static3)\.)?mediasetplay\.mediaset\.it/
22 (?:video|on-demand)/(?:[^/]+/)+[^/]+_|
23 player/index\.html\?.*?\bprogramGuid=
29 'url': 'https://www.mediasetplay.mediaset.it/video/hellogoodbye/quarta-puntata_FAFU000000661824',
30 'md5': '9b75534d42c44ecef7bf1ffeacb7f85d',
32 'id': 'FAFU000000661824',
34 'title': 'Quarta puntata',
35 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
36 'thumbnail': r're:^https?://.*\.jpg$',
38 'upload_date': '20161107',
39 'series': 'Hello Goodbye',
40 'timestamp': 1478532900,
45 'url': 'https://www.mediasetplay.mediaset.it/video/matrix/puntata-del-25-maggio_F309013801000501',
46 'md5': '288532f0ad18307705b01e581304cd7b',
48 'id': 'F309013801000501',
50 'title': 'Puntata del 25 maggio',
51 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
52 'thumbnail': r're:^https?://.*\.jpg$',
54 'upload_date': '20180526',
56 'timestamp': 1527326245,
57 'uploader': 'Canale 5',
60 'expected_warnings': ['HTTP Error 403: Forbidden'],
63 'url': 'https://www.mediasetplay.mediaset.it/video/gogglebox/un-grande-classico-della-commedia-sexy_FAFU000000661680',
64 'only_matching': True,
67 'url': 'https://static3.mediasetplay.mediaset.it/player/index.html?appKey=5ad3966b1de1c4000d5cec48&programGuid=FAFU000000665924&id=665924',
68 'only_matching': True,
70 # iframe twitter (from http://www.wittytv.it/se-prima-mi-fidavo-zero/)
71 'url': 'https://static3.mediasetplay.mediaset.it/player/index.html?appKey=5ad3966b1de1c4000d5cec48&programGuid=FAFU000000665104&id=665104',
72 'only_matching': True,
74 'url': 'mediaset:FAFU000000665924',
75 'only_matching': True,
79 def _extract_urls(webpage):
82 for mobj in re.finditer(
83 r'<iframe\b[^>]+\bsrc=(["\'])(?P<url>https?://(?:www\.)?video\.mediaset\.it/player/playerIFrame(?:Twitter)?\.shtml\?.*?\bid=\d+.*?)\1',
86 def _real_extract(self, url):
87 guid = self._match_id(url)
88 tp_path = 'PR1GhC/media/guid/2702976343/' + guid
89 info = self._extract_theplatform_metadata(tp_path, guid)
94 for asset_type in ('SD', 'HD'):
95 for f in ('MPEG4', 'MPEG-DASH', 'M3U', 'ISM'):
97 tp_formats, tp_subtitles = self._extract_theplatform_smil(
98 update_url_query('http://link.theplatform.%s/s/%s' % (self._TP_TLD, tp_path), {
101 'assetTypes': asset_type,
102 }), guid, 'Downloading %s %s SMIL data' % (f, asset_type))
103 except ExtractorError as e:
107 for tp_f in tp_formats:
108 tp_f['quality'] = 1 if asset_type == 'HD' else 0
109 formats.extend(tp_formats)
110 subtitles = self._merge_subtitles(subtitles, tp_subtitles)
111 if first_e and not formats:
113 self._sort_formats(formats)
116 for templ, repls in (('tvSeason%sNumber', ('', 'Episode')), ('mediasetprogram$%s', ('brandTitle', 'numberOfViews', 'publishInfo'))):
117 fields.extend(templ % repl for repl in repls)
118 feed_data = self._download_json(
119 'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs/guid/-/' + guid,
120 guid, fatal=False, query={'fields': ','.join(fields)})
122 publish_info = feed_data.get('mediasetprogram$publishInfo') or {}
124 'episode_number': int_or_none(feed_data.get('tvSeasonEpisodeNumber')),
125 'season_number': int_or_none(feed_data.get('tvSeasonNumber')),
126 'series': feed_data.get('mediasetprogram$brandTitle'),
127 'uploader': publish_info.get('description'),
128 'uploader_id': publish_info.get('channel'),
129 'view_count': int_or_none(feed_data.get('mediasetprogram$numberOfViews')),
135 'subtitles': subtitles,