[mediaset] Fix issues and extract all formats (closes #16568)

pull/16871/head
Sergey M․ 7 years ago
parent 9cf648c92b
commit 267d81962a
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

@ -10,7 +10,6 @@ from ..utils import (
parse_duration,
try_get,
unified_strdate,
ExtractorError
)
@ -58,7 +57,7 @@ class MediasetIE(InfoExtractor):
'series': 'Matrix',
'categories': ['infotainment'],
},
'expected_warnings': ['is not a supported codec'],
'expected_warnings': ['HTTP Error 403: Forbidden'],
}, {
# clip
'url': 'http://www.video.mediaset.it/video/gogglebox/clip/un-grande-classico-della-commedia-sexy_661680.html',
@ -87,13 +86,14 @@ class MediasetIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
media_info = self._download_json(
video = self._download_json(
'https://www.video.mediaset.it/html/metainfo.sjson',
video_id, 'Downloading media info', query={
'id': video_id
})['video']
media_id = try_get(media_info, lambda x: x['guid']) or video_id
title = video['title']
media_id = video.get('guid') or video_id
video_list = self._download_json(
'http://cdnsel01.mediaset.net/GetCdn2018.aspx',
@ -104,12 +104,17 @@ class MediasetIE(InfoExtractor):
formats = []
for format_url in video_list:
if '.ism' in format_url:
try:
formats.extend(self._extract_ism_formats(
format_url, video_id, ism_id='mss', fatal=False))
except ExtractorError:
pass
ext = determine_ext(format_url)
if ext == 'm3u8':
formats.extend(self._extract_m3u8_formats(
format_url, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls', fatal=False))
elif ext == 'mpd':
formats.extend(self._extract_mpd_formats(
format_url, video_id, mpd_id='dash', fatal=False))
elif ext == 'ism' or '.ism' in format_url:
formats.extend(self._extract_ism_formats(
format_url, video_id, ism_id='mss', fatal=False))
else:
formats.append({
'url': format_url,
@ -117,24 +122,23 @@ class MediasetIE(InfoExtractor):
})
self._sort_formats(formats)
title = media_info['title']
creator = try_get(
media_info, lambda x: x['brand-info']['publisher'], compat_str)
video, lambda x: x['brand-info']['publisher'], compat_str)
category = try_get(
media_info, lambda x: x['brand-info']['category'], compat_str)
video, lambda x: x['brand-info']['category'], compat_str)
categories = [category] if category else None
return {
'id': video_id,
'title': title,
'description': media_info.get('short-description'),
'thumbnail': media_info.get('thumbnail'),
'duration': parse_duration(media_info.get('duration')),
'description': video.get('short-description'),
'thumbnail': video.get('thumbnail'),
'duration': parse_duration(video.get('duration')),
'creator': creator,
'upload_date': unified_strdate(media_info.get('production-date')),
'webpage_url': media_info.get('url'),
'series': media_info.get('brand-value'),
'upload_date': unified_strdate(video.get('production-date')),
'webpage_url': video.get('url'),
'series': video.get('brand-value'),
'season': video.get('season'),
'categories': categories,
'formats': formats,
}

Loading…
Cancel
Save