1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-11-01 07:05:14 +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

@@ -14,6 +14,7 @@ from ..utils import (
float_or_none,
mimetype2ext,
str_or_none,
try_call,
try_get,
unescapeHTML,
unsmuggle_url,
@@ -145,11 +146,11 @@ class MediasiteIE(InfoExtractor):
'duration': slide['Time'] / 1000,
})
next_time = try_get(None, [
lambda _: Stream['Slides'][i + 1]['Time'],
lambda _: duration,
lambda _: slide['Time'],
], expected_type=(int, float))
next_time = try_call(
lambda: Stream['Slides'][i + 1]['Time'],
lambda: duration,
lambda: slide['Time'],
expected_type=(int, float))
fragments.append({
'path': fname_template.format(slide.get('Number', i + 1)),