[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
This commit is contained in:
pukkandan 2021-12-30 08:43:40 +05:30
parent 2c539d493a
commit abbeeebc4c
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698
4 changed files with 12 additions and 6 deletions

View file

@ -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):