diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-12-30 08:43:40 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-12-30 08:44:18 +0530 |
commit | abbeeebc4c20bc5c690d96c83e91e89effd04b81 (patch) | |
tree | 4e7d0e862180de6818efad0d4f438a36c3bf36ea /yt_dlp/utils.py | |
parent | 2c539d493a4fa69ac89e77bacc7497e0b2d72426 (diff) | |
download | hypervideo-pre-abbeeebc4c20bc5c690d96c83e91e89effd04b81.tar.lz hypervideo-pre-abbeeebc4c20bc5c690d96c83e91e89effd04b81.tar.xz hypervideo-pre-abbeeebc4c20bc5c690d96c83e91e89effd04b81.zip |
[outtmpl] Alternate form for `D` and fix suffix's case
Fixes: https://github.com/yt-dlp/yt-dlp/issues/2085#issuecomment-1002247689, https://github.com/yt-dlp/yt-dlp/pull/2132/files#r775729811
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 788bf16b7..c22aeb464 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -2116,9 +2116,11 @@ def format_decimal_suffix(num, fmt='%d%s', *, factor=1000): if num is None: return None exponent = 0 if num == 0 else int(math.log(num, factor)) - suffix = ['', *'KMGTPEZY'][exponent] + suffix = ['', *'kMGTPEZY'][exponent] + if factor == 1024: + suffix = {'k': 'Ki', '': ''}.get(suffix, f'{suffix}i') converted = num / (factor ** exponent) - return fmt % (converted, f'{suffix}i' if suffix and factor == 1024 else suffix) + return fmt % (converted, suffix) def format_bytes(bytes): |