From 3e16daf0a12fc43c2087300a02560879688c7f18 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Sun, 12 Aug 2012 00:38:07 +0200 Subject: update depositfiles, easybytes, add ryushare --- module/plugins/internal/SimpleHoster.py | 15 +++++++---- module/plugins/internal/XFSPAccount.py | 44 ++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 19 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 09b496aa9..566615120 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -40,18 +40,23 @@ def set_cookies(cj, cookies): def parseHtmlTagAttrValue(attr_name, tag): m = re.search(r"%s\s*=\s*([\"']?)((?<=\")[^\"]+|(?<=')[^']+|[^\s\"'][^>\s]+)\1" % attr_name, tag) - return m.group(2) if m else '' - + return m.group(2) if m else None + def parseHtmlForm(attr_str, html): inputs = {} action = None form = re.search(r"(?P]*%s[^>]*>)(?P.*?)]*>" % attr_str, html, re.S | re.I) if form: action = parseHtmlTagAttrValue("action", form.group('tag')) - for input in re.finditer(r'(<(?:input|textarea)[^>]*>)', form.group('content'), re.S | re.I): + for input in re.finditer(r'(<(input|textarea)[^>]*>)([^<]*(?=Premium account expire:([^<]+)' TRAFFIC_LEFT_PATTERN = r'Traffic available today:(?P[^<]+)' - - def loadAccountInfo(self, user, req): + + def loadAccountInfo(self, user, req): html = req.load(self.MAIN_PAGE + "?op=my_account", decode = True) - validuntil = -1 + validuntil = trafficleft = None + premium = True if '>Renew premium<' in html else False + found = re.search(self.VALID_UNTIL_PATTERN, html) if found: premium = True + trafficleft = -1 try: self.logDebug(found.group(1)) validuntil = mktime(strptime(found.group(1), "%d %B %Y")) except Exception, e: self.logError(e) else: - premium = False - - trafficleft = -1 + found = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if found: + trafficleft = found.group(1) + if "Unlimited" in trafficleft: + premium = True + else: + trafficleft = parseFileSize(trafficleft) / 1024 return ({"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium}) def login(self, user, data, req): - html = req.load(self.MAIN_PAGE, post = { - "login": user, - "op": "login", - "password": data['password'], - "redirect": self.MAIN_PAGE - }, decode = True) + html = req.load('%slogin.html' % self.MAIN_PAGE, decode = True) + + action, inputs = parseHtmlForm('name="FL"', html) + if not action: + action = self.MAIN_PAGE + if not inputs: + inputs = {"op": "login", + "redirect": self.MAIN_PAGE} + + inputs.update({"login": user, + "password": data['password']}) + + html = req.load(action, post = inputs, decode = True) - if 'Incorrect Login or Password' in html: + if 'Incorrect Login or Password' in html or '>Error<' in html: self.wrongPassword() \ No newline at end of file -- cgit v1.2.3