- for format_id, format_url in info['streams'].items():
- if format_url.endswith('.f4m'):
- token = self._download_xml(
- 'http://tp.srgssr.ch/token/akahd.xml?stream=%s/*' % compat_urllib_parse_urlparse(format_url).path,
- video_id, 'Downloading %s token' % format_id)
- auth_params = xpath_text(token, './/authparams', 'auth params')
- if not auth_params:
- continue
- formats.extend(self._extract_f4m_formats(
- '%s?%s&hdcore=3.4.0&plugin=aasp-3.4.0.132.66' % (format_url, auth_params),
- video_id, f4m_id=format_id))
- elif format_url.endswith('.m3u8'):
- formats.extend(self._extract_m3u8_formats(
- format_url, video_id, 'mp4', m3u8_id=format_id))
+ streams = info.get('streams', {})
+ for format_id, format_url in streams.items():
+ if format_id == 'hds_sd' and 'hds' in streams:
+ continue
+ if format_id == 'hls_sd' and 'hls' in streams:
+ continue
+ ext = determine_ext(format_url)
+ if ext in ('m3u8', 'f4m'):
+ format_url = self._get_tokenized_src(format_url, media_id, format_id)
+ if ext == 'f4m':
+ formats.extend(self._extract_f4m_formats(
+ format_url + ('?' if '?' not in format_url else '&') + 'hdcore=3.4.0',
+ media_id, f4m_id=format_id, fatal=False))
+ else:
+ formats.extend(self._extract_m3u8_formats(
+ format_url, media_id, 'mp4', 'm3u8_native', m3u8_id=format_id, fatal=False))