mirror of
https://github.com/l1ving/youtube-dl
synced 2020-11-18 19:53:54 -08:00
[mediaset] rewrite for the new site (close #16977)
This commit is contained in:
parent
79367a9820
commit
4b69f68c40
@ -1,144 +1,70 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
from .theplatform import ThePlatformFeedIE
|
||||||
|
|
||||||
from .common import InfoExtractor
|
|
||||||
from ..compat import compat_str
|
|
||||||
from ..utils import (
|
|
||||||
determine_ext,
|
|
||||||
parse_duration,
|
|
||||||
try_get,
|
|
||||||
unified_strdate,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class MediasetIE(InfoExtractor):
|
class MediasetIE(ThePlatformFeedIE):
|
||||||
_VALID_URL = r'''(?x)
|
_VALID_URL = r'''(?x)
|
||||||
(?:
|
(?:
|
||||||
mediaset:|
|
mediaset:|
|
||||||
https?://
|
https?://
|
||||||
(?:www\.)?video\.mediaset\.it/
|
(?:www\.)?mediasetplay\.mediaset\.it/video/
|
||||||
(?:
|
(?:[^/]+/)
|
||||||
(?:video|on-demand)/(?:[^/]+/)+[^/]+_|
|
(?:[^/_]+)_
|
||||||
player/playerIFrame(?:Twitter)?\.shtml\?.*?\bid=
|
)(?P<id>F[0-9]+)
|
||||||
)
|
|
||||||
)(?P<id>[0-9]+)
|
|
||||||
'''
|
'''
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
# full episode
|
# full episode
|
||||||
'url': 'http://www.video.mediaset.it/video/hello_goodbye/full/quarta-puntata_661824.html',
|
'url': 'https://www.mediasetplay.mediaset.it/video/temptationisland/lunedi-16-luglio-seconda-puntata_F309179001000201',
|
||||||
'md5': '9b75534d42c44ecef7bf1ffeacb7f85d',
|
'md5': 'aea24e52e32bf3e1dae8e0c54c7a1370',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '661824',
|
'id': 'F309179001000201',
|
||||||
'ext': 'mp4',
|
'ext': 'mpd',
|
||||||
'title': 'Quarta puntata',
|
'title': 'Lunedì 16 luglio - Seconda puntata',
|
||||||
'description': 'md5:7183696d6df570e3412a5ef74b27c5e2',
|
'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'duration': 1414,
|
'duration': 10045.01,
|
||||||
'creator': 'mediaset',
|
'upload_date': '20180717',
|
||||||
'upload_date': '20161107',
|
'uploader': 'FINC-MSIT',
|
||||||
'series': 'Hello Goodbye',
|
'timestamp': 1531789469,
|
||||||
'categories': ['reality'],
|
}
|
||||||
},
|
|
||||||
'expected_warnings': ['is not a supported codec'],
|
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.video.mediaset.it/video/matrix/full_chiambretti/puntata-del-25-maggio_846685.html',
|
'url': 'https://www.mediasetplay.mediaset.it/video/beforewego/before-we-go_F307046901000103',
|
||||||
'md5': '1276f966ac423d16ba255ce867de073e',
|
'md5': '50eba7a60b5142ae232a1d9858d84e57',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '846685',
|
'id': 'F307046901000103',
|
||||||
'ext': 'mp4',
|
'ext': 'mpd',
|
||||||
'title': 'Puntata del 25 maggio',
|
'title': 'Before we go',
|
||||||
'description': 'md5:ee2e456e3eb1dba5e814596655bb5296',
|
'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'duration': 6565,
|
'duration': 5478.014,
|
||||||
'creator': 'mediaset',
|
'upload_date': '20180714',
|
||||||
'upload_date': '20180525',
|
'uploader': 'FINC-MSIT',
|
||||||
'series': 'Matrix',
|
'timestamp': 1531529416,
|
||||||
'categories': ['infotainment'],
|
}
|
||||||
},
|
|
||||||
'expected_warnings': ['HTTP Error 403: Forbidden'],
|
|
||||||
}, {
|
|
||||||
# clip
|
|
||||||
'url': 'http://www.video.mediaset.it/video/gogglebox/clip/un-grande-classico-della-commedia-sexy_661680.html',
|
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
|
||||||
# iframe simple
|
|
||||||
'url': 'http://www.video.mediaset.it/player/playerIFrame.shtml?id=665924&autoplay=true',
|
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
|
||||||
# iframe twitter (from http://www.wittytv.it/se-prima-mi-fidavo-zero/)
|
|
||||||
'url': 'https://www.video.mediaset.it/player/playerIFrameTwitter.shtml?id=665104&playrelated=false&autoplay=false&related=true&hidesocial=true',
|
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
|
||||||
'url': 'mediaset:661824',
|
|
||||||
'only_matching': True,
|
|
||||||
}]
|
}]
|
||||||
|
|
||||||
@staticmethod
|
def _download_theplatform_metadata(self, path, video_id):
|
||||||
def _extract_urls(webpage):
|
info_url = 'http://link.theplatform.eu/s/%s?format=preview' % path
|
||||||
return [
|
return self._download_json(info_url, video_id)
|
||||||
mobj.group('url')
|
|
||||||
for mobj in re.finditer(
|
|
||||||
r'<iframe\b[^>]+\bsrc=(["\'])(?P<url>https?://(?:www\.)?video\.mediaset\.it/player/playerIFrame(?:Twitter)?\.shtml\?.*?\bid=\d+.*?)\1',
|
|
||||||
webpage)]
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
provider_id = 'PR1GhC'
|
||||||
|
real_url = 'https://feed.entertainment.tv.theplatform.eu/f/%s/mediaset-prod-all-programs?byGuid=%s' % (provider_id, video_id)
|
||||||
|
entry = self._download_json(real_url, video_id)['entries'][0]
|
||||||
|
|
||||||
video = self._download_json(
|
theplatform_id = entry['media'][0]['pid']
|
||||||
'https://www.video.mediaset.it/html/metainfo.sjson',
|
smil_url = 'https://link.theplatform.eu/s/%s/media/%s?format=smil' % (provider_id, theplatform_id)
|
||||||
video_id, 'Downloading media info', query={
|
formats, subtitles = self._extract_theplatform_smil(smil_url, video_id)
|
||||||
'id': video_id
|
|
||||||
})['video']
|
|
||||||
|
|
||||||
title = video['title']
|
path = provider_id + '/media/' + theplatform_id
|
||||||
media_id = video.get('guid') or video_id
|
ret = self._extract_theplatform_metadata(path, video_id)
|
||||||
|
ret.update({
|
||||||
video_list = self._download_json(
|
|
||||||
'http://cdnsel01.mediaset.net/GetCdn2018.aspx',
|
|
||||||
video_id, 'Downloading video CDN JSON', query={
|
|
||||||
'streamid': media_id,
|
|
||||||
'format': 'json',
|
|
||||||
})['videoList']
|
|
||||||
|
|
||||||
formats = []
|
|
||||||
for format_url in video_list:
|
|
||||||
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,
|
|
||||||
'format_id': determine_ext(format_url),
|
|
||||||
})
|
|
||||||
self._sort_formats(formats)
|
|
||||||
|
|
||||||
creator = try_get(
|
|
||||||
video, lambda x: x['brand-info']['publisher'], compat_str)
|
|
||||||
category = try_get(
|
|
||||||
video, lambda x: x['brand-info']['category'], compat_str)
|
|
||||||
categories = [category] if category else None
|
|
||||||
|
|
||||||
return {
|
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
|
||||||
'description': video.get('short-description'),
|
|
||||||
'thumbnail': video.get('thumbnail'),
|
|
||||||
'duration': parse_duration(video.get('duration')),
|
|
||||||
'creator': creator,
|
|
||||||
'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,
|
'formats': formats,
|
||||||
}
|
'subtitles': subtitles,
|
||||||
|
})
|
||||||
|
|
||||||
|
return ret
|
||||||
|
Loading…
x
Reference in New Issue
Block a user