From 9020c0b7a71f2734add26c2311523e3666fa8225 Mon Sep 17 00:00:00 2001 From: repic Date: Tue, 12 Nov 2013 10:09:43 +0100 Subject: [PATCH] Fixed ZeroDivisionError Fixed ZeroDivisionError if there are no leechers. --- pirate-get.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pirate-get.py b/pirate-get.py index 0140239..e1096a0 100755 --- a/pirate-get.py +++ b/pirate-get.py @@ -105,7 +105,10 @@ def main(): name = re.search("dn=([^\&]*)", magnet[0]) # compute the S/L ratio (Higher is better) - ratio = float(magnet[1])/float(magnet[2]) + try: + ratio = float(magnet[1])/float(magnet[2]) + except ZeroDivisionError: + ratio = 0 # 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("+", " ") )