-# coding: utf-8
-from __future__ import unicode_literals
-
from .common import InfoExtractor
from ..utils import (
int_or_none,
qualities,
+ try_call,
try_get,
ExtractorError,
)
metadata = self._download_json('https://api.whowatch.tv/lives/%s' % video_id, video_id)
live_data = self._download_json('https://api.whowatch.tv/lives/%s/play' % video_id, video_id)
- title = try_get(None, (
- lambda x: live_data['share_info']['live_title'][1:-1],
- lambda x: metadata['live']['title'],
- ), compat_str)
+ title = try_call(
+ lambda: live_data['share_info']['live_title'][1:-1],
+ lambda: metadata['live']['title'],
+ expected_type=str)
hls_url = live_data.get('hls_url')
if not hls_url:
if hls_url:
hls_fmts = self._extract_m3u8_formats(
- hls_url, video_id, ext='mp4', entry_protocol='m3u8',
- m3u8_id='hls-%s' % name, quality=quality)
+ hls_url, video_id, ext='mp4', m3u8_id='hls-%s' % name, quality=quality)
formats.extend(hls_fmts)
else:
hls_fmts = []
# This contains the same formats as the above manifests and is used only as a fallback
formats.extend(self._extract_m3u8_formats(
- hls_url, video_id, ext='mp4', entry_protocol='m3u8',
- m3u8_id='hls'))
+ hls_url, video_id, ext='mp4', m3u8_id='hls'))
self._remove_duplicate_formats(formats)
- self._sort_formats(formats)
uploader_url = try_get(metadata, lambda x: x['live']['user']['user_path'], compat_str)
if uploader_url: