diff options
Diffstat (limited to 'pyload/plugins/internal/XFSPAccount.py')
-rw-r--r-- | pyload/plugins/internal/XFSPAccount.py | 73 |
1 files changed, 47 insertions, 26 deletions
diff --git a/pyload/plugins/internal/XFSPAccount.py b/pyload/plugins/internal/XFSPAccount.py index 058fdf2b5..edf6ad3cc 100644 --- a/pyload/plugins/internal/XFSPAccount.py +++ b/pyload/plugins/internal/XFSPAccount.py @@ -2,6 +2,7 @@ import re +from urlparse import urljoin from time import mktime, strptime from pyload.plugins.base.Account import Account @@ -12,62 +13,82 @@ from pyload.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.07" + __version__ = "0.09" __description__ = """XFileSharingPro base account plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] HOSTER_URL = None COOKIES = None #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:</TD><TD><b>([^<]+)</b>' - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:</TD><TD><b>([^<]+)</b>' - LOGIN_FAIL_PATTERN = r'Incorrect Login or Password|>Error<' - PREMIUM_PATTERN = r'>Renew premium<' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?<b>(.+?)</b>' + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?<b>(?P<S>.+?)</b>' + LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' + # PREMIUM_PATTERN = r'>Renew premium<' def loadAccountInfo(self, user, req): - html = req.load(self.HOSTER_URL + "?op=my_account", decode=True) + html = req.load(self.HOSTER_URL, get={'op': "my_account"}, decode=True) - validuntil = trafficleft = None - premium = True if re.search(self.PREMIUM_PATTERN, html) else False + validuntil = None + trafficleft = None + premium = None + + if hasattr(self, "PREMIUM_PATTERN"): + premium = True if re.search(self.PREMIUM_PATTERN, html) else False m = re.search(self.VALID_UNTIL_PATTERN, html) if m: - premium = True - trafficleft = -1 + expiredate = m.group(1) + self.logDebug("Expire date: " + expiredate) + try: - self.logDebug(m.group(1)) - validuntil = mktime(strptime(m.group(1), "%d %B %Y")) + validuntil = mktime(strptime(expiredate, "%d %B %Y")) except Exception, e: self.logError(e) - else: - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m: - trafficleft = m.group(1) - if "Unlimited" in trafficleft: + else: + if validuntil > mktime(gmtime()): premium = True + trafficleft = -1 else: - trafficleft = parseFileSize(trafficleft) / 1024 + if premium is False: #: registered account type (not premium) + validuntil = -1 + premium = False + + 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: + trafficleft = -1 + if premium is None: + premium = True + else: + trafficleft = parseFileSize(trafficsize) + except: + pass + + if premium is None: + premium = False - return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} def login(self, user, data, req): set_cookies(req.cj, self.COOKIES) - html = req.load('%slogin.html' % self.HOSTER_URL, decode=True) + url = urljoin(self.HOSTER_URL, "login.html") + html = req.load(url, decode=True) action, inputs = parseHtmlForm('name="FL"', html) if not inputs: - inputs = {"op": "login", - "redirect": self.HOSTER_URL} + inputs = {'op': "login", + 'redirect': self.HOSTER_URL} - inputs.update({"login": user, - "password": data['password']}) + inputs.update({'login': user, + 'password': data['password']}) html = req.load(self.HOSTER_URL, post=inputs, decode=True) |