- webpage = self._download_webpage(url, video_id)
- video_params = self._parse_json(self._search_regex(
- r'videoParams\s*=\s*({.+?});', webpage, 'video params'), video_id)
- title = video_params['title']
- stream = next(s for s in video_params['playlist'] if s.get('type') == 'program')
-
- formats = []
- f4m_url = stream.get('hds-unmetered') or stream['hds-metered']
- formats.extend(self._extract_f4m_formats(
- update_url_query(f4m_url, {'hdcore': '3.7.0'}),
- video_id, f4m_id='hds', fatal=False))
- formats.extend(self._extract_m3u8_formats(f4m_url.replace(
- 'akamaihd.net/z/', 'akamaihd.net/i/').replace('/manifest.f4m', '/master.m3u8'),
- video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
+ video_params = self._download_json(
+ 'https://iview.abc.net.au/api/programs/' + video_id, video_id)
+ title = unescapeHTML(video_params.get('title') or video_params['seriesTitle'])
+ stream = next(s for s in video_params['playlist'] if s.get('type') in ('program', 'livestream'))
+
+ house_number = video_params.get('episodeHouseNumber') or video_id
+ path = '/auth/hls/sign?ts={0}&hn={1}&d=android-tablet'.format(
+ int(time.time()), house_number)
+ sig = hmac.new(
+ b'android.content.res.Resources',
+ path.encode('utf-8'), hashlib.sha256).hexdigest()
+ token = self._download_webpage(
+ 'http://iview.abc.net.au{0}&sig={1}'.format(path, sig), video_id)
+
+ def tokenize_url(url, token):
+ return update_url_query(url, {
+ 'hdnea': token,
+ })
+
+ for sd in ('720', 'sd', 'sd-low'):
+ sd_url = try_get(
+ stream, lambda x: x['streams']['hls'][sd], compat_str)
+ if not sd_url:
+ continue
+ formats = self._extract_m3u8_formats(
+ tokenize_url(sd_url, token), video_id, 'mp4',
+ entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
+ if formats:
+ break