[periscope] Renew HLS extraction (closes #13917)

This commit is contained in:
Sergey M․ 2017-08-16 23:03:42 +07:00
parent 4850478543
commit a1aa659662
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -80,18 +80,24 @@ def _real_extract(self, url):
stream = self._call_api( stream = self._call_api(
'getAccessPublic', {'broadcast_id': token}, token) 'getAccessPublic', {'broadcast_id': token}, token)
video_urls = set()
formats = [] formats = []
for format_id in ('replay', 'rtmp', 'hls', 'https_hls'): for format_id in ('replay', 'rtmp', 'hls', 'https_hls', 'lhls', 'lhlsweb'):
video_url = stream.get(format_id + '_url') video_url = stream.get(format_id + '_url')
if not video_url: if not video_url or video_url in video_urls:
continue continue
f = { video_urls.add(video_url)
if format_id != 'rtmp':
formats.extend(self._extract_m3u8_formats(
video_url, token, 'mp4',
entry_protocol='m3u8_native'
if state in ('ended', 'timed_out') else 'm3u8',
m3u8_id=format_id, fatal=False))
continue
formats.append({
'url': video_url, 'url': video_url,
'ext': 'flv' if format_id == 'rtmp' else 'mp4', 'ext': 'flv' if format_id == 'rtmp' else 'mp4',
} })
if format_id != 'rtmp':
f['protocol'] = 'm3u8_native' if state in ('ended', 'timed_out') else 'm3u8'
formats.append(f)
self._sort_formats(formats) self._sort_formats(formats)
return { return {