summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-10-15 02:04:25 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-10-15 02:04:25 +0200
commit93106fbef7579707e2918bcd9694e4a21b37d390 (patch)
tree34865c661d26881e541aa37017a62e90051f8edc /module/plugins
parentImprove unit detection in size pattern (diff)
downloadpyload-93106fbef7579707e2918bcd9694e4a21b37d390.tar.xz
[XFSPAccount] Improve TRAFFIC_LEFT_PATTERN
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/internal/XFSPAccount.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py
index 18543b9cd..9191b71a0 100644
--- a/module/plugins/internal/XFSPAccount.py
+++ b/module/plugins/internal/XFSPAccount.py
@@ -13,7 +13,7 @@ from module.utils import parseFileSize
class XFSPAccount(Account):
__name__ = "XFSPAccount"
__type__ = "account"
- __version__ = "0.10"
+ __version__ = "0.11"
__description__ = """XFileSharingPro account plugin"""
__license__ = "GPLv3"
@@ -26,8 +26,12 @@ class XFSPAccount(Account):
COOKIES = None #: or list of tuples [(domain, name, value)]
VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?<b>(.+?)</b>'
- TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?<b>(?P<S>.+?)</b>'
+
+ TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?<b>\s*(?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)\s*</b>'
+ TRAFFIC_LEFT_UNIT = "MB" #: used only if no group <U> was found
+
LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)'
+
# PREMIUM_PATTERN = r'>Renew premium<'
@@ -61,13 +65,18 @@ class XFSPAccount(Account):
try:
traffic = re.search(self.TRAFFIC_LEFT_PATTERN, html).groupdict()
- trafficsize = traffic['S'] + traffic['U'] if 'U' in traffic else traffic['S']
- if "Unlimited" in trafficsize:
+ if "Unlimited" in traffic['S']:
trafficleft = -1
if premium is None:
premium = True
else:
- trafficleft = parseFileSize(trafficsize)
+ if 'U' in traffic:
+ unit = traffic['U']
+ elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring):
+ unit = self.TRAFFIC_LEFT_UNIT
+ else:
+ unit = None
+ trafficleft = parseFileSize(traffic['S'], unit)
except:
pass