Fix minor problem with size formatting method
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>
Sat, 8 Aug 2009 12:54:39 +0000 (14:54 +0200)
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>
Sun, 31 Oct 2010 10:24:44 +0000 (11:24 +0100)
youtube-dl

index aa16ff1e4ced11af45527fdf602a85c9a914f37f..1dfd355566adc90625480dcefdc9fc628a539109 100755 (executable)
@@ -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)