aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>2009-08-08 14:54:39 +0200
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-10-31 11:24:44 +0100
commit8497c36d5af77dc561fa698968bffea868a71f3c (patch)
tree82264a134d002ea8515bcf853449edb00f9cabd6
parent110cd3462e4057ccbec5369bf895bdf311fb536b (diff)
Fix minor problem with size formatting method
-rwxr-xr-xyoutube-dl6
1 files changed, 4 insertions, 2 deletions
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)