1
0
Fork 0

[utils] Add try_call

This commit is contained in:
pukkandan 2022-03-31 13:19:16 +05:30
commit c4f60dd7cd
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
5 changed files with 25 additions and 19 deletions

View file

@ -5,6 +5,7 @@ from .common import InfoExtractor
from ..utils import (
int_or_none,
qualities,
try_call,
try_get,
ExtractorError,
)
@ -26,10 +27,10 @@ class WhoWatchIE(InfoExtractor):
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: