1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-10 10:04:21 +01:00

Fixed ZeroDivisionError

Fixed ZeroDivisionError if there are no leechers.
This commit is contained in:
repic 2013-11-12 10:09:43 +01:00
parent 9bcb47e0d3
commit 9020c0b7a7

View File

@ -105,7 +105,10 @@ def main():
name = re.search("dn=([^\&]*)", magnet[0]) name = re.search("dn=([^\&]*)", magnet[0])
# compute the S/L ratio (Higher is better) # compute the S/L ratio (Higher is better)
try:
ratio = float(magnet[1])/float(magnet[2]) ratio = float(magnet[1])/float(magnet[2])
except ZeroDivisionError:
ratio = 0
# enhanced print output with justified columns # enhanced print output with justified columns
print "%-5s %-6s %-6s %5.1f %-11s %s" % (m, magnet[1], magnet[2], ratio ,sizes[m], urllib.unquote(name.group(1).encode('ascii')).decode('utf-8').replace("+", " ") ) print "%-5s %-6s %-6s %5.1f %-11s %s" % (m, magnet[1], magnet[2], ratio ,sizes[m], urllib.unquote(name.group(1).encode('ascii')).decode('utf-8').replace("+", " ") )