This commit is contained in:
Vitaly Khabarov 2024-04-28 10:17:38 +05:30 committed by GitHub
commit c48324d5c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 13 deletions

View File

@ -7,6 +7,7 @@ from ..utils import (
int_or_none,
parse_duration,
parse_iso8601,
try_get,
unescapeHTML,
urljoin,
)
@ -20,7 +21,6 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
_TESTS = [
{
'url': 'http://www.rts.ch/archives/tv/divers/3449373-les-enfants-terribles.html',
'md5': '753b877968ad8afaeddccc374d4256a5',
'info_dict': {
'id': '3449373',
'display_id': 'les-enfants-terribles',
@ -34,6 +34,7 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
'thumbnail': r're:^https?://.*\.image',
'view_count': int,
},
'params': {'skip_download': 'm3u8'},
'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'],
},
{
@ -43,6 +44,7 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
'title': 'Passe-moi les jumelles',
},
'playlist_mincount': 4,
'skip': '404 Page Not Found',
},
{
'url': 'http://www.rts.ch/video/sport/hockey/5745975-1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski.html',
@ -59,16 +61,12 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
'thumbnail': r're:^https?://.*\.image',
'view_count': int,
},
'params': {
# m3u8 download
'skip_download': True,
},
'params': {'skip_download': 'm3u8'},
'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'],
'skip': 'Blocked outside Switzerland',
},
{
'url': 'http://www.rts.ch/video/info/journal-continu/5745356-londres-cachee-par-un-epais-smog.html',
'md5': '9bb06503773c07ce83d3cbd793cebb91',
'info_dict': {
'id': '5745356',
'display_id': 'londres-cachee-par-un-epais-smog',
@ -82,6 +80,7 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
'thumbnail': r're:^https?://.*\.image',
'view_count': int,
},
'params': {'skip_download': 'm3u8'},
'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'],
},
{
@ -106,6 +105,7 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
'title': 'Hockey: Davos décroche son 31e titre de champion de Suisse',
},
'playlist_mincount': 5,
'skip': 'Blocked outside Switzerland',
},
{
'url': 'http://pages.rts.ch/emissions/passe-moi-les-jumelles/5624065-entre-ciel-et-mer.html',
@ -155,14 +155,15 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
return self.playlist_result(entries, media_id, all_info.get('title'))
internal_id = self._html_search_regex(
r'<(?:video|audio) data-id="([0-9]+)"', page,
r'(?:<(?:video|audio)\s+data-id\s*=\s*"|data-media-urn\s*=\s*"urn:rts:(?:video|audio):)(\d+)"', page,
'internal video id')
all_info = download_json(internal_id)
media_id = internal_id
media_type = 'video' if 'video' in all_info else 'audio'
# check for errors
self._get_media_data('rts', media_type, media_id)
media_info = self._get_media_data('rts', media_type, media_id)
info = all_info['video']['JSONinfo'] if 'video' in all_info else all_info['audio']
@ -173,8 +174,15 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
r'-([0-9]+)k\.', url, 'bitrate', default=None))
formats = []
def streams_from_media_data(m_data):
return dict(
(res.get('protocol', i), res['url'], )
for i, res in enumerate(try_get(m_data, lambda x: x['resourceList'], list), 1)
if try_get(res, lambda x: x['url']))
streams = info.get('streams', {})
for format_id, format_url in streams.items():
for format_id, format_url in (streams_from_media_data(media_info) or streams).items():
if format_id == 'hds_sd' and 'hds' in streams:
continue
if format_id == 'hls_sd' and 'hls' in streams:
@ -196,14 +204,14 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
'tbr': extract_bitrate(format_url),
})
download_base = 'http://rtsww%s-d.rts.ch/' % ('-a' if media_type == 'audio' else '')
download_base = info.get('download', 'http://rtsww%s-d.rts.ch/' % ('-a' if media_type == 'audio' else '', ))
for media in info.get('media', []):
media_url = media.get('url')
if not media_url or re.match(r'https?://', media_url):
continue
rate = media.get('rate')
ext = media.get('ext') or determine_ext(media_url, 'mp4')
format_id = ext
format_id = (re.findall(r'_[A-Za-z\d]+\.', media_url) or ('_%s.' % (ext, )))[-1][1:-1]
if rate:
format_id += '-%dk' % rate
formats.append({

View File

@ -57,7 +57,7 @@ class SRGSSRIE(InfoExtractor):
def _get_media_data(self, bu, media_type, media_id):
query = {'onlyChapters': True} if media_type == 'video' else {}
full_media_data = self._download_json(
'https://il.srgssr.ch/integrationlayer/2.0/%s/mediaComposition/%s/%s.json'
'https://il.srgssr.ch/integrationlayer/2.0/mediaComposition/byUrn/urn:%s:%s:%s.json'
% (bu, media_type, media_id),
media_id, query=query)['chapterList']
try:
@ -166,7 +166,7 @@ class SRGSSRPlayIE(InfoExtractor):
_TESTS = [{
'url': 'http://www.srf.ch/play/tv/10vor10/video/snowden-beantragt-asyl-in-russland?id=28e1a57d-5b76-4399-8ab3-9097f071e6c5',
'md5': '6db2226ba97f62ad42ce09783680046c',
'md5': '465bd9be85833a9472275796e97091ed',
'info_dict': {
'id': '28e1a57d-5b76-4399-8ab3-9097f071e6c5',
'ext': 'mp4',
@ -186,6 +186,7 @@ class SRGSSRPlayIE(InfoExtractor):
'title': 'Saira: Tujetsch - tuttina cuntinuar cun Sedrun Mustér Turissem',
'timestamp': 1444709160,
'duration': 336.816,
'thumbnail': r're:https?://ws\.srf\.ch/asset/image/.+/\d+\.jpg',
},
'params': {
# rtmp download