diff options
author | dirkf <fieldhouse@gmx.net> | 2022-01-27 01:09:00 +0000 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2022-01-27 05:38:13 +0000 |
commit | 5ed91cf9d0f514b894bda08dc40415ba96f3cb95 (patch) | |
tree | c8ff828983bd472ba8203ab733032ab3b55e3c47 | |
parent | cad0ff54113d578eb4033ca300b9b735ebabd626 (diff) | |
download | youtube-dl-5ed91cf9d0f514b894bda08dc40415ba96f3cb95.tar.gz youtube-dl-5ed91cf9d0f514b894bda08dc40415ba96f3cb95.tar.xz youtube-dl-5ed91cf9d0f514b894bda08dc40415ba96f3cb95.zip |
Simplify init_or_none(), based on yt-dlp 9e907ebddf9c9c3084fb1b24156c9e3786ab428e
Also swallow inf, nan
-rw-r--r-- | youtube_dl/utils.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 1e5291285..2de3556a2 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -3694,16 +3694,11 @@ class PUTRequest(compat_urllib_request.Request): def int_or_none(v, scale=1, default=None, get_attr=None, invscale=1): - if get_attr: - if v is not None: - v = getattr(v, get_attr, None) - if v == '': - v = None - if v is None: - return default + if get_attr and v is not None: + v = getattr(v, get_attr, None) try: return int(v) * invscale // scale - except (ValueError, TypeError): + except (ValueError, TypeError, OverflowError): return default |