1
0
Fork 0
mirror of https://gitlab.com/dstftw/youtube-dl.git synced 2020-11-16 09:42:26 +00:00

Remove longs (int does the right thing since Python 2.2, see PEP 237)

This commit is contained in:
Philipp Hagemeister 2012-11-26 04:13:43 +01:00
parent 51937c0869
commit 7ec1a206ea

View file

@ -139,23 +139,23 @@ class FileDownloader(object):
new_min = max(bytes / 2.0, 1.0) new_min = max(bytes / 2.0, 1.0)
new_max = min(max(bytes * 2.0, 1.0), 4194304) # Do not surpass 4 MB new_max = min(max(bytes * 2.0, 1.0), 4194304) # Do not surpass 4 MB
if elapsed_time < 0.001: if elapsed_time < 0.001:
return long(new_max) return int(new_max)
rate = bytes / elapsed_time rate = bytes / elapsed_time
if rate > new_max: if rate > new_max:
return long(new_max) return int(new_max)
if rate < new_min: if rate < new_min:
return long(new_min) return int(new_min)
return long(rate) return int(rate)
@staticmethod @staticmethod
def parse_bytes(bytestr): def parse_bytes(bytestr):
"""Parse a string indicating a byte quantity into a long integer.""" """Parse a string indicating a byte quantity into an integer."""
matchobj = re.match(r'(?i)^(\d+(?:\.\d+)?)([kMGTPEZY]?)$', bytestr) matchobj = re.match(r'(?i)^(\d+(?:\.\d+)?)([kMGTPEZY]?)$', bytestr)
if matchobj is None: if matchobj is None:
return None return None
number = float(matchobj.group(1)) number = float(matchobj.group(1))
multiplier = 1024.0 ** 'bkmgtpezy'.index(matchobj.group(2).lower()) multiplier = 1024.0 ** 'bkmgtpezy'.index(matchobj.group(2).lower())
return long(round(number * multiplier)) return int(round(number * multiplier))
def add_info_extractor(self, ie): def add_info_extractor(self, ie):
"""Add an InfoExtractor object to the end of the list.""" """Add an InfoExtractor object to the end of the list."""