2020-11-16 16:17:52 +00:00
|
|
|
# coding: utf-8
|
2014-06-13 16:44:44 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2017-04-01 19:14:42 +00:00
|
|
|
import re
|
|
|
|
|
2015-02-18 19:14:42 +00:00
|
|
|
from .common import InfoExtractor
|
2017-04-01 19:14:42 +00:00
|
|
|
from ..compat import (
|
|
|
|
compat_urlparse,
|
|
|
|
compat_str,
|
|
|
|
)
|
2014-06-13 16:44:44 +00:00
|
|
|
from ..utils import (
|
2016-07-03 07:39:24 +00:00
|
|
|
ExtractorError,
|
2017-03-14 15:11:09 +00:00
|
|
|
determine_ext,
|
2016-07-03 07:39:24 +00:00
|
|
|
find_xpath_attr,
|
|
|
|
fix_xml_ampersands,
|
2017-04-01 19:14:42 +00:00
|
|
|
GeoRestrictedError,
|
2016-07-03 07:39:24 +00:00
|
|
|
int_or_none,
|
2014-06-13 16:44:44 +00:00
|
|
|
parse_duration,
|
2020-11-20 09:01:56 +00:00
|
|
|
remove_start,
|
2017-04-01 19:14:42 +00:00
|
|
|
strip_or_none,
|
2020-11-20 09:01:56 +00:00
|
|
|
try_get,
|
2014-06-13 16:44:44 +00:00
|
|
|
unified_strdate,
|
2017-04-01 19:14:42 +00:00
|
|
|
unified_timestamp,
|
2016-07-03 07:39:24 +00:00
|
|
|
update_url_query,
|
2017-04-01 19:14:42 +00:00
|
|
|
urljoin,
|
2015-12-25 14:38:12 +00:00
|
|
|
xpath_text,
|
2014-06-13 16:44:44 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2016-07-03 11:22:48 +00:00
|
|
|
class RaiBaseIE(InfoExtractor):
|
2017-04-01 19:14:42 +00:00
|
|
|
_UUID_RE = r'[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}'
|
|
|
|
_GEO_COUNTRIES = ['IT']
|
|
|
|
_GEO_BYPASS = False
|
|
|
|
|
|
|
|
def _extract_relinker_info(self, relinker_url, video_id):
|
2018-07-26 07:11:06 +00:00
|
|
|
if not re.match(r'https?://', relinker_url):
|
|
|
|
return {'formats': [{'url': relinker_url}]}
|
|
|
|
|
2016-07-03 11:22:48 +00:00
|
|
|
formats = []
|
2017-04-01 19:14:42 +00:00
|
|
|
geoprotection = None
|
|
|
|
is_live = None
|
|
|
|
duration = None
|
2016-07-03 11:22:48 +00:00
|
|
|
|
|
|
|
for platform in ('mon', 'flash', 'native'):
|
|
|
|
relinker = self._download_xml(
|
|
|
|
relinker_url, video_id,
|
|
|
|
note='Downloading XML metadata for platform %s' % platform,
|
|
|
|
transform_source=fix_xml_ampersands,
|
2016-07-03 15:23:48 +00:00
|
|
|
query={'output': 45, 'pl': platform},
|
|
|
|
headers=self.geo_verification_headers())
|
2016-07-03 11:22:48 +00:00
|
|
|
|
2017-04-01 19:14:42 +00:00
|
|
|
if not geoprotection:
|
|
|
|
geoprotection = xpath_text(
|
|
|
|
relinker, './geoprotection', default=None) == 'Y'
|
|
|
|
|
|
|
|
if not is_live:
|
|
|
|
is_live = xpath_text(
|
|
|
|
relinker, './is_live', default=None) == 'Y'
|
|
|
|
if not duration:
|
|
|
|
duration = parse_duration(xpath_text(
|
|
|
|
relinker, './duration', default=None))
|
|
|
|
|
|
|
|
url_elem = find_xpath_attr(relinker, './url', 'type', 'content')
|
|
|
|
if url_elem is None:
|
|
|
|
continue
|
|
|
|
|
|
|
|
media_url = url_elem.text
|
|
|
|
|
|
|
|
# This does not imply geo restriction (e.g.
|
|
|
|
# http://www.raisport.rai.it/dl/raiSport/media/rassegna-stampa-04a9f4bd-b563-40cf-82a6-aad3529cb4a9.html)
|
2020-11-20 09:10:57 +00:00
|
|
|
if '/video_no_available.mp4' in media_url:
|
2017-04-01 19:14:42 +00:00
|
|
|
continue
|
2016-07-03 11:22:48 +00:00
|
|
|
|
|
|
|
ext = determine_ext(media_url)
|
|
|
|
if (ext == 'm3u8' and platform != 'mon') or (ext == 'f4m' and platform != 'flash'):
|
|
|
|
continue
|
|
|
|
|
2019-03-05 16:54:25 +00:00
|
|
|
if ext == 'm3u8' or 'format=m3u8' in media_url or platform == 'mon':
|
2016-07-03 11:22:48 +00:00
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
media_url, video_id, 'mp4', 'm3u8_native',
|
|
|
|
m3u8_id='hls', fatal=False))
|
2019-03-05 16:54:25 +00:00
|
|
|
elif ext == 'f4m' or platform == 'flash':
|
2016-07-03 11:22:48 +00:00
|
|
|
manifest_url = update_url_query(
|
|
|
|
media_url.replace('manifest#live_hds.f4m', 'manifest.f4m'),
|
|
|
|
{'hdcore': '3.7.0', 'plugin': 'aasp-3.7.0.39.44'})
|
|
|
|
formats.extend(self._extract_f4m_formats(
|
|
|
|
manifest_url, video_id, f4m_id='hds', fatal=False))
|
|
|
|
else:
|
|
|
|
bitrate = int_or_none(xpath_text(relinker, 'bitrate'))
|
|
|
|
formats.append({
|
|
|
|
'url': media_url,
|
|
|
|
'tbr': bitrate if bitrate > 0 else None,
|
|
|
|
'format_id': 'http-%d' % bitrate if bitrate > 0 else 'http',
|
|
|
|
})
|
|
|
|
|
2017-04-01 19:14:42 +00:00
|
|
|
if not formats and geoprotection is True:
|
|
|
|
self.raise_geo_restricted(countries=self._GEO_COUNTRIES)
|
|
|
|
|
|
|
|
return dict((k, v) for k, v in {
|
|
|
|
'is_live': is_live,
|
|
|
|
'duration': duration,
|
|
|
|
'formats': formats,
|
|
|
|
}.items() if v is not None)
|
2016-07-03 11:22:48 +00:00
|
|
|
|
2017-04-08 07:11:03 +00:00
|
|
|
@staticmethod
|
2021-01-07 13:48:45 +00:00
|
|
|
def _extract_subtitles(url, video_data):
|
|
|
|
STL_EXT = 'stl'
|
|
|
|
SRT_EXT = 'srt'
|
2017-04-08 07:11:03 +00:00
|
|
|
subtitles = {}
|
2021-01-07 13:48:45 +00:00
|
|
|
subtitles_array = video_data.get('subtitlesArray') or []
|
|
|
|
for k in ('subtitles', 'subtitlesUrl'):
|
|
|
|
subtitles_array.append({'url': video_data.get(k)})
|
|
|
|
for subtitle in subtitles_array:
|
|
|
|
sub_url = subtitle.get('url')
|
|
|
|
if sub_url and isinstance(sub_url, compat_str):
|
|
|
|
sub_lang = subtitle.get('language') or 'it'
|
|
|
|
sub_url = urljoin(url, sub_url)
|
|
|
|
sub_ext = determine_ext(sub_url, SRT_EXT)
|
|
|
|
subtitles.setdefault(sub_lang, []).append({
|
|
|
|
'ext': sub_ext,
|
|
|
|
'url': sub_url,
|
2017-04-08 07:11:03 +00:00
|
|
|
})
|
2021-01-07 13:48:45 +00:00
|
|
|
if STL_EXT == sub_ext:
|
|
|
|
subtitles[sub_lang].append({
|
|
|
|
'ext': SRT_EXT,
|
|
|
|
'url': sub_url[:-len(STL_EXT)] + SRT_EXT,
|
|
|
|
})
|
2017-04-08 07:11:03 +00:00
|
|
|
return subtitles
|
|
|
|
|
2016-07-03 11:44:58 +00:00
|
|
|
|
2017-03-14 15:11:09 +00:00
|
|
|
class RaiPlayIE(RaiBaseIE):
|
2020-11-20 09:01:56 +00:00
|
|
|
_VALID_URL = r'(?P<base>https?://(?:www\.)?raiplay\.it/.+?-(?P<id>%s))\.(?:html|json)' % RaiBaseIE._UUID_RE
|
2017-03-14 15:11:09 +00:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'http://www.raiplay.it/video/2014/04/Report-del-07042014-cb27157f-9dd0-4aee-b788-b1f67643a391.html',
|
|
|
|
'md5': '8970abf8caf8aef4696e7b1f2adfc696',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'cb27157f-9dd0-4aee-b788-b1f67643a391',
|
|
|
|
'ext': 'mp4',
|
2017-04-01 19:14:42 +00:00
|
|
|
'title': 'Report del 07/04/2014',
|
2020-11-16 16:17:52 +00:00
|
|
|
'alt_title': 'St 2013/14 - Espresso nel caffè - 07/04/2014',
|
|
|
|
'description': 'md5:d730c168a58f4bb35600fc2f881ec04e',
|
2017-03-14 15:11:09 +00:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2020-11-16 16:17:52 +00:00
|
|
|
'uploader': 'Rai Gulp',
|
2017-04-01 19:14:42 +00:00
|
|
|
'duration': 6160,
|
|
|
|
'series': 'Report',
|
|
|
|
'season': '2013/14',
|
2021-01-07 13:48:45 +00:00
|
|
|
'subtitles': {
|
|
|
|
'it': 'count:2',
|
|
|
|
},
|
2017-04-01 19:14:42 +00:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
'url': 'http://www.raiplay.it/video/2016/11/gazebotraindesi-efebe701-969c-4593-92f3-285f0d1ce750.html?',
|
|
|
|
'only_matching': True,
|
2021-01-07 13:48:45 +00:00
|
|
|
}, {
|
|
|
|
# subtitles at 'subtitlesArray' key (see #27698)
|
|
|
|
'url': 'https://www.raiplay.it/video/2020/12/Report---04-01-2021-2e90f1de-8eee-4de4-ac0e-78d21db5b600.html',
|
|
|
|
'only_matching': True,
|
2017-03-14 15:11:09 +00:00
|
|
|
}]
|
2016-07-03 11:44:58 +00:00
|
|
|
|
2017-03-14 15:11:09 +00:00
|
|
|
def _real_extract(self, url):
|
2020-11-20 09:01:56 +00:00
|
|
|
base, video_id = re.match(self._VALID_URL, url).groups()
|
2016-07-03 11:44:58 +00:00
|
|
|
|
2017-04-01 19:14:42 +00:00
|
|
|
media = self._download_json(
|
2020-11-20 09:01:56 +00:00
|
|
|
base + '.json', video_id, 'Downloading video JSON')
|
2016-07-03 11:44:58 +00:00
|
|
|
|
2017-04-01 19:14:42 +00:00
|
|
|
title = media['name']
|
|
|
|
|
|
|
|
video = media['video']
|
|
|
|
|
2020-11-16 16:17:52 +00:00
|
|
|
relinker_info = self._extract_relinker_info(video['content_url'], video_id)
|
2017-04-01 19:14:42 +00:00
|
|
|
self._sort_formats(relinker_info['formats'])
|
2016-07-03 11:44:58 +00:00
|
|
|
|
2017-03-14 15:11:09 +00:00
|
|
|
thumbnails = []
|
2020-11-16 16:17:52 +00:00
|
|
|
for _, value in media.get('images', {}).items():
|
|
|
|
if value:
|
|
|
|
thumbnails.append({
|
|
|
|
'url': urljoin(url, value),
|
|
|
|
})
|
2016-07-03 11:22:48 +00:00
|
|
|
|
2020-11-16 16:17:52 +00:00
|
|
|
date_published = media.get('date_published')
|
|
|
|
time_published = media.get('time_published')
|
|
|
|
if date_published and time_published:
|
|
|
|
date_published += ' ' + time_published
|
2014-06-13 16:44:44 +00:00
|
|
|
|
2021-01-07 13:48:45 +00:00
|
|
|
subtitles = self._extract_subtitles(url, video)
|
2017-04-08 07:11:03 +00:00
|
|
|
|
2020-11-16 16:17:52 +00:00
|
|
|
program_info = media.get('program_info') or {}
|
|
|
|
season = media.get('season')
|
|
|
|
|
2017-04-01 19:14:42 +00:00
|
|
|
info = {
|
2020-11-20 09:01:56 +00:00
|
|
|
'id': remove_start(media.get('id'), 'ContentItem-') or video_id,
|
|
|
|
'display_id': video_id,
|
2017-06-24 18:48:02 +00:00
|
|
|
'title': self._live_title(title) if relinker_info.get(
|
|
|
|
'is_live') else title,
|
2020-11-16 16:17:52 +00:00
|
|
|
'alt_title': strip_or_none(media.get('subtitle')),
|
2017-04-01 19:14:42 +00:00
|
|
|
'description': media.get('description'),
|
2017-06-24 18:48:02 +00:00
|
|
|
'uploader': strip_or_none(media.get('channel')),
|
2020-11-16 16:17:52 +00:00
|
|
|
'creator': strip_or_none(media.get('editor') or None),
|
2017-04-01 19:14:42 +00:00
|
|
|
'duration': parse_duration(video.get('duration')),
|
2020-11-16 16:17:52 +00:00
|
|
|
'timestamp': unified_timestamp(date_published),
|
2017-03-14 15:11:09 +00:00
|
|
|
'thumbnails': thumbnails,
|
2020-11-16 16:17:52 +00:00
|
|
|
'series': program_info.get('name'),
|
|
|
|
'season_number': int_or_none(season),
|
|
|
|
'season': season if (season and not season.isdigit()) else None,
|
|
|
|
'episode': media.get('episode_title'),
|
|
|
|
'episode_number': int_or_none(media.get('episode')),
|
2017-04-08 07:11:03 +00:00
|
|
|
'subtitles': subtitles,
|
2017-03-14 15:11:09 +00:00
|
|
|
}
|
2014-06-13 16:44:44 +00:00
|
|
|
|
2017-04-01 19:14:42 +00:00
|
|
|
info.update(relinker_info)
|
|
|
|
return info
|
|
|
|
|
2015-12-25 14:38:12 +00:00
|
|
|
|
2020-11-20 09:01:56 +00:00
|
|
|
class RaiPlayLiveIE(RaiPlayIE):
|
2020-11-20 09:00:05 +00:00
|
|
|
_VALID_URL = r'(?P<base>https?://(?:www\.)?raiplay\.it/dirette/(?P<id>[^/?#&]+))'
|
2020-11-20 09:01:56 +00:00
|
|
|
_TESTS = [{
|
2017-06-24 18:48:02 +00:00
|
|
|
'url': 'http://www.raiplay.it/dirette/rainews24',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'd784ad40-e0ae-4a69-aa76-37519d238a9c',
|
|
|
|
'display_id': 'rainews24',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 're:^Diretta di Rai News 24 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
|
2020-11-20 09:00:05 +00:00
|
|
|
'description': 'md5:4d00bcf6dc98b27c6ec480de329d1497',
|
2017-06-24 18:48:02 +00:00
|
|
|
'uploader': 'Rai News 24',
|
|
|
|
'creator': 'Rai News 24',
|
|
|
|
'is_live': True,
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2020-11-20 09:01:56 +00:00
|
|
|
}]
|
2020-11-20 09:00:05 +00:00
|
|
|
|
2017-06-17 15:15:41 +00:00
|
|
|
|
2017-12-08 17:46:28 +00:00
|
|
|
class RaiPlayPlaylistIE(InfoExtractor):
|
2020-11-20 09:00:05 +00:00
|
|
|
_VALID_URL = r'(?P<base>https?://(?:www\.)?raiplay\.it/programmi/(?P<id>[^/?#&]+))'
|
2017-12-08 17:46:28 +00:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'http://www.raiplay.it/programmi/nondirloalmiocapo/',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'nondirloalmiocapo',
|
|
|
|
'title': 'Non dirlo al mio capo',
|
2020-11-20 09:00:05 +00:00
|
|
|
'description': 'md5:98ab6b98f7f44c2843fd7d6f045f153b',
|
2017-12-08 17:46:28 +00:00
|
|
|
},
|
|
|
|
'playlist_mincount': 12,
|
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2020-11-20 09:01:56 +00:00
|
|
|
base, playlist_id = re.match(self._VALID_URL, url).groups()
|
2017-12-08 17:46:28 +00:00
|
|
|
|
2020-11-20 09:01:56 +00:00
|
|
|
program = self._download_json(
|
|
|
|
base + '.json', playlist_id, 'Downloading program JSON')
|
2017-12-08 17:46:28 +00:00
|
|
|
|
|
|
|
entries = []
|
2020-11-20 09:01:56 +00:00
|
|
|
for b in (program.get('blocks') or []):
|
|
|
|
for s in (b.get('sets') or []):
|
|
|
|
s_id = s.get('id')
|
|
|
|
if not s_id:
|
2020-11-20 09:00:05 +00:00
|
|
|
continue
|
|
|
|
medias = self._download_json(
|
2020-11-20 09:01:56 +00:00
|
|
|
'%s/%s.json' % (base, s_id), s_id,
|
|
|
|
'Downloading content set JSON', fatal=False)
|
2020-11-20 09:00:05 +00:00
|
|
|
if not medias:
|
|
|
|
continue
|
2020-11-20 09:01:56 +00:00
|
|
|
for m in (medias.get('items') or []):
|
|
|
|
path_id = m.get('path_id')
|
|
|
|
if not path_id:
|
|
|
|
continue
|
|
|
|
video_url = urljoin(url, path_id)
|
2020-11-20 09:00:05 +00:00
|
|
|
entries.append(self.url_result(
|
|
|
|
video_url, ie=RaiPlayIE.ie_key(),
|
|
|
|
video_id=RaiPlayIE._match_id(video_url)))
|
2017-12-08 17:46:28 +00:00
|
|
|
|
2020-11-20 09:01:56 +00:00
|
|
|
return self.playlist_result(
|
|
|
|
entries, playlist_id, program.get('name'),
|
|
|
|
try_get(program, lambda x: x['program_info']['description']))
|
2017-12-08 17:46:28 +00:00
|
|
|
|
|
|
|
|
2016-07-03 11:22:48 +00:00
|
|
|
class RaiIE(RaiBaseIE):
|
2019-02-15 16:56:29 +00:00
|
|
|
_VALID_URL = r'https?://[^/]+\.(?:rai\.(?:it|tv)|rainews\.it)/.+?-(?P<id>%s)(?:-.+?)?\.html' % RaiBaseIE._UUID_RE
|
2017-03-14 15:11:09 +00:00
|
|
|
_TESTS = [{
|
2017-04-01 19:14:42 +00:00
|
|
|
# var uniquename = "ContentItem-..."
|
|
|
|
# data-id="ContentItem-..."
|
2017-03-14 15:11:09 +00:00
|
|
|
'url': 'http://www.raisport.rai.it/dl/raiSport/media/rassegna-stampa-04a9f4bd-b563-40cf-82a6-aad3529cb4a9.html',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '04a9f4bd-b563-40cf-82a6-aad3529cb4a9',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'TG PRIMO TEMPO',
|
2017-04-01 19:14:42 +00:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2017-03-14 15:11:09 +00:00
|
|
|
'duration': 1758,
|
2017-04-01 19:14:42 +00:00
|
|
|
'upload_date': '20140612',
|
2020-11-16 16:17:52 +00:00
|
|
|
},
|
|
|
|
'skip': 'This content is available only in Italy',
|
2017-03-14 15:11:09 +00:00
|
|
|
}, {
|
2017-04-01 19:14:42 +00:00
|
|
|
# with ContentItem in many metas
|
2017-03-14 15:11:09 +00:00
|
|
|
'url': 'http://www.rainews.it/dl/rainews/media/Weekend-al-cinema-da-Hollywood-arriva-il-thriller-di-Tate-Taylor-La-ragazza-del-treno-1632c009-c843-4836-bb65-80c33084a64b.html',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '1632c009-c843-4836-bb65-80c33084a64b',
|
|
|
|
'ext': 'mp4',
|
2017-04-01 19:14:42 +00:00
|
|
|
'title': 'Weekend al cinema, da Hollywood arriva il thriller di Tate Taylor "La ragazza del treno"',
|
|
|
|
'description': 'I film in uscita questa settimana.',
|
2017-03-14 15:11:09 +00:00
|
|
|
'thumbnail': r're:^https?://.*\.png$',
|
2017-04-01 19:14:42 +00:00
|
|
|
'duration': 833,
|
|
|
|
'upload_date': '20161103',
|
2017-03-14 15:11:09 +00:00
|
|
|
}
|
|
|
|
}, {
|
2017-04-01 19:14:42 +00:00
|
|
|
# with ContentItem in og:url
|
2017-03-14 15:11:09 +00:00
|
|
|
'url': 'http://www.rai.it/dl/RaiTV/programmi/media/ContentItem-efb17665-691c-45d5-a60c-5301333cbb0c.html',
|
2020-11-16 16:17:52 +00:00
|
|
|
'md5': '6865dd00cf0bbf5772fdd89d59bd768a',
|
2017-03-14 15:11:09 +00:00
|
|
|
'info_dict': {
|
|
|
|
'id': 'efb17665-691c-45d5-a60c-5301333cbb0c',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'TG1 ore 20:00 del 03/11/2016',
|
2017-04-01 19:14:42 +00:00
|
|
|
'description': 'TG1 edizione integrale ore 20:00 del giorno 03/11/2016',
|
2017-03-14 15:11:09 +00:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2017-04-01 19:14:42 +00:00
|
|
|
'duration': 2214,
|
2017-03-14 15:11:09 +00:00
|
|
|
'upload_date': '20161103',
|
|
|
|
}
|
|
|
|
}, {
|
2017-04-01 19:14:42 +00:00
|
|
|
# initEdizione('ContentItem-...'
|
|
|
|
'url': 'http://www.tg1.rai.it/dl/tg1/2010/edizioni/ContentSet-9b6e0cba-4bef-4aef-8cf0-9f7f665b7dfb-tg1.html?item=undefined',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'c2187016-8484-4e3a-8ac8-35e475b07303',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': r're:TG1 ore \d{2}:\d{2} del \d{2}/\d{2}/\d{4}',
|
|
|
|
'duration': 2274,
|
|
|
|
'upload_date': '20170401',
|
|
|
|
},
|
|
|
|
'skip': 'Changes daily',
|
2017-03-14 15:11:09 +00:00
|
|
|
}, {
|
2017-04-01 19:14:42 +00:00
|
|
|
# HLS live stream with ContentItem in og:url
|
2017-03-14 15:11:09 +00:00
|
|
|
'url': 'http://www.rainews.it/dl/rainews/live/ContentItem-3156f2f2-dc70-4953-8e2f-70d7489d4ce9.html',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '3156f2f2-dc70-4953-8e2f-70d7489d4ce9',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'La diretta di Rainews24',
|
2016-07-03 11:48:50 +00:00
|
|
|
},
|
2017-04-01 19:14:42 +00:00
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2021-01-05 18:49:56 +00:00
|
|
|
}, {
|
2021-01-07 13:48:45 +00:00
|
|
|
# ContentItem in iframe (see #12652) and subtitle at 'subtitlesUrl' key
|
2021-01-05 18:49:56 +00:00
|
|
|
'url': 'http://www.presadiretta.rai.it/dl/portali/site/puntata/ContentItem-3ed19d13-26c2-46ff-a551-b10828262f1b.html',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '1ad6dc64-444a-42a4-9bea-e5419ad2f5fd',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Partiti acchiappavoti - Presa diretta del 13/09/2015',
|
|
|
|
'description': 'md5:d291b03407ec505f95f27970c0b025f4',
|
|
|
|
'upload_date': '20150913',
|
2021-01-07 13:48:45 +00:00
|
|
|
'subtitles': {
|
|
|
|
'it': 'count:2',
|
|
|
|
},
|
2021-01-05 18:49:56 +00:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2018-07-26 07:11:06 +00:00
|
|
|
}, {
|
|
|
|
# Direct MMS URL
|
|
|
|
'url': 'http://www.rai.it/dl/RaiTV/programmi/media/ContentItem-b63a4089-ac28-48cf-bca5-9f5b5bc46df5.html',
|
|
|
|
'only_matching': True,
|
2019-02-15 16:56:29 +00:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.rainews.it/tgr/marche/notiziari/video/2019/02/ContentItem-6ba945a2-889c-4a80-bdeb-8489c70a8db9.html',
|
|
|
|
'only_matching': True,
|
2017-03-14 15:11:09 +00:00
|
|
|
}]
|
2015-12-25 14:38:12 +00:00
|
|
|
|
2017-03-14 15:11:09 +00:00
|
|
|
def _extract_from_content_id(self, content_id, url):
|
|
|
|
media = self._download_json(
|
|
|
|
'http://www.rai.tv/dl/RaiTV/programmi/media/ContentItem-%s.html?json' % content_id,
|
|
|
|
content_id, 'Downloading video JSON')
|
|
|
|
|
2017-04-01 19:14:42 +00:00
|
|
|
title = media['name'].strip()
|
|
|
|
|
|
|
|
media_type = media['type']
|
|
|
|
if 'Audio' in media_type:
|
|
|
|
relinker_info = {
|
2017-08-26 15:02:49 +00:00
|
|
|
'formats': [{
|
2017-04-01 19:14:42 +00:00
|
|
|
'format_id': media.get('formatoAudio'),
|
|
|
|
'url': media['audioUrl'],
|
|
|
|
'ext': media.get('formatoAudio'),
|
2017-08-26 15:02:49 +00:00
|
|
|
}]
|
2017-04-01 19:14:42 +00:00
|
|
|
}
|
|
|
|
elif 'Video' in media_type:
|
|
|
|
relinker_info = self._extract_relinker_info(media['mediaUri'], content_id)
|
|
|
|
else:
|
|
|
|
raise ExtractorError('not a media file')
|
|
|
|
|
|
|
|
self._sort_formats(relinker_info['formats'])
|
|
|
|
|
2017-03-14 15:11:09 +00:00
|
|
|
thumbnails = []
|
|
|
|
for image_type in ('image', 'image_medium', 'image_300'):
|
|
|
|
thumbnail_url = media.get(image_type)
|
|
|
|
if thumbnail_url:
|
|
|
|
thumbnails.append({
|
|
|
|
'url': compat_urlparse.urljoin(url, thumbnail_url),
|
|
|
|
})
|
|
|
|
|
2021-01-07 13:48:45 +00:00
|
|
|
subtitles = self._extract_subtitles(url, media)
|
2017-03-14 15:11:09 +00:00
|
|
|
|
2017-04-01 19:14:42 +00:00
|
|
|
info = {
|
2017-03-14 15:11:09 +00:00
|
|
|
'id': content_id,
|
2017-04-01 19:14:42 +00:00
|
|
|
'title': title,
|
|
|
|
'description': strip_or_none(media.get('desc')),
|
2017-03-14 15:11:09 +00:00
|
|
|
'thumbnails': thumbnails,
|
|
|
|
'uploader': media.get('author'),
|
|
|
|
'upload_date': unified_strdate(media.get('date')),
|
|
|
|
'duration': parse_duration(media.get('length')),
|
|
|
|
'subtitles': subtitles,
|
|
|
|
}
|
2017-04-01 19:14:42 +00:00
|
|
|
|
|
|
|
info.update(relinker_info)
|
|
|
|
|
|
|
|
return info
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
|
|
|
content_item_id = None
|
|
|
|
|
|
|
|
content_item_url = self._html_search_meta(
|
|
|
|
('og:url', 'og:video', 'og:video:secure_url', 'twitter:url',
|
|
|
|
'twitter:player', 'jsonlink'), webpage, default=None)
|
|
|
|
if content_item_url:
|
|
|
|
content_item_id = self._search_regex(
|
|
|
|
r'ContentItem-(%s)' % self._UUID_RE, content_item_url,
|
|
|
|
'content item id', default=None)
|
|
|
|
|
|
|
|
if not content_item_id:
|
|
|
|
content_item_id = self._search_regex(
|
|
|
|
r'''(?x)
|
|
|
|
(?:
|
|
|
|
(?:initEdizione|drawMediaRaiTV)\(|
|
2021-01-05 18:49:56 +00:00
|
|
|
<(?:[^>]+\bdata-id|var\s+uniquename)=|
|
|
|
|
<iframe[^>]+\bsrc=
|
2017-04-01 19:14:42 +00:00
|
|
|
)
|
|
|
|
(["\'])
|
|
|
|
(?:(?!\1).)*\bContentItem-(?P<id>%s)
|
|
|
|
''' % self._UUID_RE,
|
|
|
|
webpage, 'content item id', default=None, group='id')
|
|
|
|
|
|
|
|
content_item_ids = set()
|
2017-04-01 19:24:13 +00:00
|
|
|
if content_item_id:
|
|
|
|
content_item_ids.add(content_item_id)
|
2017-04-01 19:14:42 +00:00
|
|
|
if video_id not in content_item_ids:
|
|
|
|
content_item_ids.add(video_id)
|
|
|
|
|
|
|
|
for content_item_id in content_item_ids:
|
|
|
|
try:
|
|
|
|
return self._extract_from_content_id(content_item_id, url)
|
|
|
|
except GeoRestrictedError:
|
|
|
|
raise
|
|
|
|
except ExtractorError:
|
|
|
|
pass
|
|
|
|
|
2020-11-20 09:26:55 +00:00
|
|
|
relinker_url = self._proto_relative_url(self._search_regex(
|
2017-04-01 19:14:42 +00:00
|
|
|
r'''(?x)
|
|
|
|
(?:
|
|
|
|
var\s+videoURL|
|
|
|
|
mediaInfo\.mediaUri
|
|
|
|
)\s*=\s*
|
|
|
|
([\'"])
|
|
|
|
(?P<url>
|
|
|
|
(?:https?:)?
|
|
|
|
//mediapolis(?:vod)?\.rai\.it/relinker/relinkerServlet\.htm\?
|
|
|
|
(?:(?!\1).)*\bcont=(?:(?!\1).)+)\1
|
|
|
|
''',
|
2020-11-20 09:26:55 +00:00
|
|
|
webpage, 'relinker URL', group='url'))
|
2017-04-01 19:14:42 +00:00
|
|
|
|
|
|
|
relinker_info = self._extract_relinker_info(
|
|
|
|
urljoin(url, relinker_url), video_id)
|
|
|
|
self._sort_formats(relinker_info['formats'])
|
|
|
|
|
|
|
|
title = self._search_regex(
|
|
|
|
r'var\s+videoTitolo\s*=\s*([\'"])(?P<title>[^\'"]+)\1',
|
|
|
|
webpage, 'title', group='title',
|
|
|
|
default=None) or self._og_search_title(webpage)
|
|
|
|
|
|
|
|
info = {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
}
|
|
|
|
|
|
|
|
info.update(relinker_info)
|
|
|
|
|
|
|
|
return info
|