Permalink
Browse files

- Added ZeroDivisionError support

  • Loading branch information...
1 parent 0475080 commit b279ab7ac766df7ff985ba179c3f1afd0cccbb9c Jérôme Renard committed Nov 17, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 fetchsubtitles.py
View
@@ -142,10 +142,15 @@ def findBestRated(self, subtitleList):
subtitle.find('p', {'title':'downloaded'}).contents[1].strip())
# not sure the formula is the good one
- current = ((bad/good + downloadCount * 2)/3)
- if current > rating:
- rating = current
- bestSubtitle = subtitle
+ try:
+ current = ((bad/good + downloadCount * 2)/3)
+ except ZeroDivisionError:
+ current = downloadCount
+ finally:
+ if current > rating:
+ rating = current
+ bestSubtitle = subtitle
+
return bestSubtitle

0 comments on commit b279ab7

Please sign in to comment.