Use float for size calculation. fix #643

This commit is contained in:
Ruud
2012-08-05 15:27:27 +02:00
parent ac91156288
commit a3895dd176
2 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ def tryInt(s):
def tryFloat(s):
try: return float(s) if '.' in s else tryInt(s)
except: return s
except: return 0
def natsortKey(s):
return map(tryInt, re.findall(r'(\d+|\D+)', s))
+6 -7
View File
@@ -1,14 +1,13 @@
from couchpotato.core.event import addEvent
from couchpotato.core.helpers.variable import tryFloat
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
from urlparse import urlparse
from urllib import quote_plus
from couchpotato.core.helpers.encoding import simplifyString
import re
import time
log = CPLog(__name__)
@@ -86,19 +85,19 @@ class YarrProvider(Provider):
def parseSize(self, size):
sizeRaw = size.lower()
size = float(re.sub(r'[^0-9.]', '', size).strip())
size = tryFloat(re.sub(r'[^0-9.]', '', size).strip())
for s in self.sizeGb:
if s in sizeRaw:
return int(size) * 1024
return size * 1024
for s in self.sizeMb:
if s in sizeRaw:
return int(size)
return size
for s in self.sizeKb:
if s in sizeRaw:
return int(size) / 1024
return size / 1024
return 0