diff options
author | Jesús <heckyel@hyperbola.info> | 2022-03-22 00:48:28 +0800 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2022-03-22 00:48:28 +0800 |
commit | 7a74bc5d1e54299e51b73492e09c70da994f4b35 (patch) | |
tree | e59a64b5b386d2381906e99912153aabd5d4ab0d /yt_dlp/utils.py | |
parent | 3c69360ec3cb4a951d7e37150c7cfae8a0491cd2 (diff) | |
parent | 84842aee2ba8dc50601c86dc6fbb12d0fa438449 (diff) | |
download | hypervideo-pre-7a74bc5d1e54299e51b73492e09c70da994f4b35.tar.lz hypervideo-pre-7a74bc5d1e54299e51b73492e09c70da994f4b35.tar.xz hypervideo-pre-7a74bc5d1e54299e51b73492e09c70da994f4b35.zip |
updated from upstream | 22/03/2022 at 00:48
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index c9b57c2f0..da6f27801 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -2279,8 +2279,9 @@ def format_decimal_suffix(num, fmt='%d%s', *, factor=1000): num, factor = float_or_none(num), float(factor) if num is None or num < 0: return None - exponent = 0 if num == 0 else int(math.log(num, factor)) - suffix = ['', *'kMGTPEZY'][exponent] + POSSIBLE_SUFFIXES = 'kMGTPEZY' + exponent = 0 if num == 0 else min(int(math.log(num, factor)), len(POSSIBLE_SUFFIXES)) + suffix = ['', *POSSIBLE_SUFFIXES][exponent] if factor == 1024: suffix = {'k': 'Ki', '': ''}.get(suffix, f'{suffix}i') converted = num / (factor ** exponent) |