1
0
mirror of https://github.com/yt-dlp/yt-dlp synced 2025-12-17 22:55:42 +07: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

@@ -18,7 +18,7 @@
parse_http_range,
sanitized_Request,
ThrottledDownload,
try_get,
try_call,
write_xattr,
XAttrMetadataError,
XAttrUnavailableError,
@@ -120,12 +120,12 @@ def establish_connection():
else:
range_end = None
if try_get(None, lambda _: range_start > range_end):
if try_call(lambda: range_start > range_end):
ctx.resume_len = 0
ctx.open_mode = 'wb'
raise RetryDownload(Exception(f'Conflicting range. (start={range_start} > end={range_end})'))
if try_get(None, lambda _: range_end >= ctx.content_len):
if try_call(lambda: range_end >= ctx.content_len):
range_end = ctx.content_len - 1
request = sanitized_Request(url, request_data, headers)