-# coding: utf-8
-from __future__ import unicode_literals
-
import re
from .srgssr import SRGSSRIE
from ..compat import compat_str
from ..utils import (
+ determine_ext,
int_or_none,
parse_duration,
parse_iso8601,
unescapeHTML,
- determine_ext,
+ urljoin,
)
-class RTSIE(SRGSSRIE):
+class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
IE_DESC = 'RTS.ch'
_VALID_URL = r'rts:(?P<rts_id>\d+)|https?://(?:.+?\.)?rts\.ch/(?:[^/]+/){2,}(?P<id>[0-9]+)-(?P<display_id>.+?)\.html'
_TESTS = [
{
'url': 'http://www.rts.ch/archives/tv/divers/3449373-les-enfants-terribles.html',
- 'md5': 'ff7f8450a90cf58dacb64e29707b4a8e',
+ 'md5': '753b877968ad8afaeddccc374d4256a5',
'info_dict': {
'id': '3449373',
'display_id': 'les-enfants-terribles',
'thumbnail': r're:^https?://.*\.image',
'view_count': int,
},
+ 'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'],
},
{
'url': 'http://www.rts.ch/emissions/passe-moi-les-jumelles/5624067-entre-ciel-et-mer.html',
# m3u8 download
'skip_download': True,
},
+ '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': '1bae984fe7b1f78e94abc74e802ed99f',
+ 'md5': '9bb06503773c07ce83d3cbd793cebb91',
'info_dict': {
'id': '5745356',
'display_id': 'londres-cachee-par-un-epais-smog',
'thumbnail': r're:^https?://.*\.image',
'view_count': int,
},
+ 'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'],
},
{
'url': 'http://www.rts.ch/audio/couleur3/programmes/la-belle-video-de-stephane-laurenceau/5706148-urban-hippie-de-damien-krisl-03-04-2014.html',
]
def _real_extract(self, url):
- m = re.match(self._VALID_URL, url)
+ m = self._match_valid_url(url)
media_id = m.group('rts_id') or m.group('id')
display_id = m.group('display_id') or media_id
if not entries:
page, urlh = self._download_webpage_handle(url, display_id)
- if re.match(self._VALID_URL, urlh.geturl()).group('id') != media_id:
- return self.url_result(urlh.geturl(), 'RTS')
+ if re.match(self._VALID_URL, urlh.url).group('id') != media_id:
+ return self.url_result(urlh.url, 'RTS')
# article with videos on rhs
videos = re.findall(
media_type = 'video' if 'video' in all_info else 'audio'
# check for errors
- self.get_media_data('rts', media_type, media_id)
+ self._get_media_data('rts', media_type, media_id)
info = all_info['video']['JSONinfo'] if 'video' in all_info else all_info['audio']
'tbr': extract_bitrate(format_url),
})
+ download_base = '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):
format_id += '-%dk' % rate
formats.append({
'format_id': format_id,
- 'url': 'http://download-video.rts.ch/' + media_url,
+ 'url': urljoin(download_base, media_url),
'tbr': rate or extract_bitrate(media_url),
})
self._check_formats(formats, media_id)
- self._sort_formats(formats)
duration = info.get('duration') or info.get('cutout') or info.get('cutduration')
if isinstance(duration, compat_str):