1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-31 06:35:12 +00:00

[utils] Add try_call

This commit is contained in:
pukkandan
2022-03-31 13:19:16 +05:30
parent f189faf1ce
commit c4f60dd7cd
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: