diff options
author | benbox69 <dev@tollet.me> | 2015-09-17 19:39:31 +0200 |
---|---|---|
committer | benbox69 <dev@tollet.me> | 2015-09-17 19:39:31 +0200 |
commit | 0c4231391834674916ec8640edbeec93d6250122 (patch) | |
tree | 5bdbfdc6825a07910948ae00f03c500eafd1e6d9 /module/plugins/accounts | |
parent | Merge pull request #1818 from jakubbroz/stable (diff) | |
download | pyload-0c4231391834674916ec8640edbeec93d6250122.tar.xz |
Update UptoboxCom.py
I rewrite the UptoboxCom account plugin because the old one doesn't work...
I am not expert in python so I just code a new plugin.
Diffstat (limited to 'module/plugins/accounts')
-rw-r--r-- | module/plugins/accounts/UptoboxCom.py | 77 |
1 files changed, 65 insertions, 12 deletions
diff --git a/module/plugins/accounts/UptoboxCom.py b/module/plugins/accounts/UptoboxCom.py index 68aaecc47..de253fa3a 100644 --- a/module/plugins/accounts/UptoboxCom.py +++ b/module/plugins/accounts/UptoboxCom.py @@ -1,19 +1,72 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.XFSAccount import XFSAccount +import json +import re +import time +from module.plugins.internal.Account import Account -class UptoboxCom(XFSAccount): - __name__ = "UptoboxCom" - __type__ = "account" - __version__ = "0.09" - __status__ = "testing" - __description__ = """DDLStorage.com account plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] +class UptoboxCom(Account): + __name__ = "UptoboxCom" + __type__ = "account" + __version__ = "0.10" + __status__ = "testing" + __description__ = """Uptobox.com account plugin""" + __license__ = "GPLv3" + __authors__ = [("benbox69", "dev@tollet.me")] - HOSTER_DOMAIN = "uptobox.com" - HOSTER_URL = "https://uptobox.com/" - LOGIN_URL = "https://login.uptobox.com/" + + HOSTER_DOMAIN = "uptobox.com" + HOSTER_URL = "https://uptobox.com/" + LOGIN_URL = "https://login.uptobox.com/logarithme" + + VALID_UNTIL_PATTERN = r'Premium-Account expire: (\d{1,2} [\w^_]+ \d{4})' + + def parse_info(self, user, password, data, req): + + validuntil = None + trafficleft = None + premium = None + + data = self.get_data(user) + html = self.load(self.HOSTER_URL, get={'op': "my_account"}) + + p = re.compile(self.VALID_UNTIL_PATTERN) + + m = re.search(p, html) + + if m: + expiredate = m.group(1).strip() + self.log_debug("Expire date: " + expiredate) + + try: + validuntil = time.mktime(time.strptime(expiredate, "%d %B %Y")) + + except Exception, e: + self.log_error(e) + + else: + self.log_debug("Valid until: %s" % validuntil) + + if validuntil > time.mktime(time.gmtime()): + premium = True + trafficleft = -1 + else: + premium = False + validuntil = None #: Registered account type (not premium) + else: + self.log_debug("VALID_UNTIL_PATTERN not found") + + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} + + + def login(self, user, password, data, req): + + jsonstring = self.load(self.LOGIN_URL, None, post={'login': user, 'password': password, 'op': 'login'}) + + parsedjson = json.loads(jsonstring) + + if parsedjson['success'] is None: + self.login_fail() |