From: Ricardo Garcia Date: Sat, 8 Aug 2009 12:54:39 +0000 (+0200) Subject: Fix minor problem with size formatting method X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=8497c36d5af77dc561fa698968bffea868a71f3c;p=youtube-dl Fix minor problem with size formatting method --- diff --git a/youtube-dl b/youtube-dl index aa16ff1e4..1dfd35556 100755 --- a/youtube-dl +++ b/youtube-dl @@ -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)