diff options
Diffstat (limited to 'module/plugins/internal')
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 15 | ||||
-rw-r--r-- | module/plugins/internal/XFSPAccount.py | 44 |
2 files changed, 40 insertions, 19 deletions
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<tag><form[^>]*%s[^>]*>)(?P<content>.*?)</(form|body|html)[^>]*>" % 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)[^>]*>)([^<]*(?=</\2)|)', form.group('content'), re.S | re.I): name = parseHtmlTagAttrValue("name", input.group(1)) if name: - inputs[name] = parseHtmlTagAttrValue("value", input.group(1)) + value = parseHtmlTagAttrValue("value", input.group(1)) + if value is None: + inputs[name] = input.group(3) or '' + else: + inputs[name] = value + return action, inputs def parseFileInfo(self, url = '', html = ''): @@ -124,7 +129,7 @@ class PluginParseError(Exception): class SimpleHoster(Hoster): __name__ = "SimpleHoster" - __version__ = "0.24" + __version__ = "0.25" __pattern__ = None __type__ = "hoster" __description__ = """Base hoster plugin""" diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index f187109b7..76bbfb9fe 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -20,10 +20,12 @@ import re from time import mktime, strptime from module.plugins.Account import Account +from module.plugins.internal.SimpleHoster import parseHtmlForm +from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" - __version__ = "0.01" + __version__ = "0.03" __type__ = "account" __description__ = """XFileSharingPro account base""" __author_name__ = ("zoidberg") @@ -33,33 +35,47 @@ class XFSPAccount(Account): VALID_UNTIL_PATTERN = r'<TR><TD>Premium account expire:</TD><TD><b>([^<]+)</b>' TRAFFIC_LEFT_PATTERN = r'<TR><TD>Traffic available today:</TD><TD><b>(?P<S>[^<]+)</b>' - - 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 |