From b20ffc3f6e6b34db2a22b6db6f751ee4a4d58a44 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 19:39:20 +0100 Subject: Assign in-line regex to PATTERN variable in a couple of accounts --- module/plugins/accounts/MegaRapidCz.py | 10 +++++++--- module/plugins/accounts/QuickshareCz.py | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'module') diff --git a/module/plugins/accounts/MegaRapidCz.py b/module/plugins/accounts/MegaRapidCz.py index 3ef98560a..04abf8c8a 100644 --- a/module/plugins/accounts/MegaRapidCz.py +++ b/module/plugins/accounts/MegaRapidCz.py @@ -18,22 +18,26 @@ class MegaRapidCz(Account): login_timeout = 60 + + LIMITDL_PATTERN = ur'Max. počet paralelních stahování: (\d+)' + VALID_UNTIL_PATTERN = ur'Paušální stahování aktivní. Vyprší (.*?)' + TRAFFIC_LEFT_PATTERN = r'Kredit(.*?) GiB' def loadAccountInfo(self, user, req): src = req.load("http://megarapid.cz/mujucet/", decode=True) - m = re.search(ur'Max. počet paralelních stahování: (\d+)', src) + m = re.search(self.LIMITDL_PATTERN, src) if m: data = self.getAccountData(user) data['options']['limitDL'] = [int(m.group(1))] - m = re.search(ur'Paušální stahování aktivní. Vyprší (.*?)', src) + m = re.search(self.VALID_UNTIL_PATTERN, src) if m: validuntil = mktime(strptime(m.group(1), "%d.%m.%Y - %H:%M")) return {"premium": True, "trafficleft": -1, "validuntil": validuntil} - m = re.search(r'Kredit(.*?) GiB', src) + m = re.search(self.TRAFFIC_LEFT_PATTERN, src) if m: trafficleft = float(m.group(1)) * (1 << 20) return {"premium": True, "trafficleft": trafficleft, "validuntil": -1} diff --git a/module/plugins/accounts/QuickshareCz.py b/module/plugins/accounts/QuickshareCz.py index adb54c7d0..f8ba3e7ff 100644 --- a/module/plugins/accounts/QuickshareCz.py +++ b/module/plugins/accounts/QuickshareCz.py @@ -15,10 +15,13 @@ class QuickshareCz(Account): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + TRAFFIC_LEFT_PATTERN = r'Stav kreditu: (.+?)' + + def loadAccountInfo(self, user, req): html = req.load("http://www.quickshare.cz/premium", decode=True) - m = re.search(r'Stav kreditu: (.+?)', html) + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) if m: trafficleft = self.parseTraffic(m.group(1)) premium = True if trafficleft else False -- cgit v1.2.3