1
0
Fork 0
mirror of https://github.com/blackjack4494/yt-dlc.git synced 2024-12-22 07:43:08 +00:00

Fix minor problem with size formatting method

This commit is contained in:
Ricardo Garcia 2009-08-08 14:54:39 +02:00
parent 110cd3462e
commit 8497c36d5a

View file

@ -143,10 +143,12 @@ class FileDownloader(object):
def format_bytes(bytes):
if bytes is None:
return 'N/A'
if bytes == 0:
if type(bytes) is str:
bytes = float(bytes)
if bytes == 0.0:
exponent = 0
else:
exponent = long(math.log(float(bytes), 1024.0))
exponent = long(math.log(bytes, 1024.0))
suffix = 'bkMGTPEZY'[exponent]
converted = float(bytes) / float(1024**exponent)
return '%.2f%s' % (converted, suffix)