diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-01-02 01:11:12 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-01-02 01:11:12 +0100 |
commit | c06dbc2e7b7fbba6ad6de3a28b4fcf21df04814d (patch) | |
tree | e2e1e53db2d4afefd3e05ccd5eaa99c500fa2c26 /module/plugins | |
parent | [RapiduNet] Fixup (diff) | |
download | pyload-c06dbc2e7b7fbba6ad6de3a28b4fcf21df04814d.tar.xz |
[RapiduNet] Fixup (2)
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/accounts/RapiduNet.py | 54 | ||||
-rw-r--r-- | module/plugins/hoster/RapiduNet.py | 32 |
2 files changed, 49 insertions, 37 deletions
diff --git a/module/plugins/accounts/RapiduNet.py b/module/plugins/accounts/RapiduNet.py index 60283e5bd..2d4770f67 100644 --- a/module/plugins/accounts/RapiduNet.py +++ b/module/plugins/accounts/RapiduNet.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- import re + +from time import time + from module.plugins.Account import Account from module.common.json_layer import json_loads @@ -8,45 +11,50 @@ from module.common.json_layer import json_loads class RapiduNet(Account): __name__ = "RapiduNet" __type__ = "account" - __version__ = "0.03" + __version__ = "0.04" __description__ = """Rapidu.net account plugin""" __license__ = "GPLv3" - __authors__ = [("prOq", None)] + __authors__ = [("prOq", None), + ("Walter Purcaro", "vuolter@gmail.com")] - PREMIUM_PATTERN = r'<a href="premium/" style="padding-left: 0px;">Account: <b>Premium</b></a>' + PREMIUM_PATTERN = r'>Account: <b>Premium' + + VALID_UNTIL_PATTERN = r'>Account: <b>\w+ \((\d+)' def loadAccountInfo(self, user, req): validuntil = None - trafficleft = None + trafficleft = -1 premium = False - req.load("https://rapidu.net/ajax.php?a=getChangeLang", - post={'_go': "", 'lang': "en"}) - html = req.load("https://rapidu.net/", decode=True) if re.search(self.PREMIUM_PATTERN, html): - premium = True - trafficleft = -1 + premium = True + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + validuntil = time() + (86400 * int(m.group(1))) return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} def login(self, user, data, req): - try: - json = json_loads(req.load("https://rapidu.net/ajax.php?a=getUserLogin", - post={'_go' : "", - 'login' : user, - 'pass' : data['password'], - 'remember': "1"})) - - self.logDebug(json) - - if not json['message'] == "success": - self.wrongPassword() - - except Exception, e: - self.logError(e) + req.load("https://rapidu.net/ajax.php", + get={'a': "getChangeLang"}, + post={'_go' : "", + 'lang': "en"}) + + json = json_loads(req.load("https://rapidu.net/ajax.php", + get={'a': "getUserLogin"}, + post={'_go' : "", + 'login' : user, + 'pass' : data['password'], + 'remember': "1"})) + + self.logDebug(json) + + if not json['message'] == "success": + self.wrongPassword() diff --git a/module/plugins/hoster/RapiduNet.py b/module/plugins/hoster/RapiduNet.py index a3b2cffcd..163edfe34 100644 --- a/module/plugins/hoster/RapiduNet.py +++ b/module/plugins/hoster/RapiduNet.py @@ -13,13 +13,13 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class RapiduNet(SimpleHoster): __name__ = "RapiduNet" __type__ = "hoster" - __version__ = "0.02" + __version__ = "0.03" __pattern__ = r'https?://(?:www\.)?rapidu\.net/(?P<ID>\d{10})' __description__ = """Rapidu.net hoster plugin""" __license__ = "GPLv3" - __authors__ = [("prOq", None)] + __authors__ = [("prOq", "")] COOKIES = [("rapidu.net", "rapidu_lang", "en")] @@ -34,22 +34,24 @@ class RapiduNet(SimpleHoster): def setup(self): self.resumeDownload = True - self.multiDL = True - self.limitDL = 0 if self.premium else 2 + self.multiDL = self.premium def handleFree(self): self.req.http.lastURL = self.pyfile.url self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) - jsvars = self.getJsonResponse("https://rapidu.net/ajax.php?a=getLoadTimeToDownload", {'_go': None}) + jsvars = self.getJsonResponse("https://rapidu.net/ajax.php", + get={'a': "getLoadTimeToDownload"}, + post={'_go': ""}, + decode=True) if str(jsvars['timeToDownload']) is "stop": - t = (24 * 60 * 60) - (int(time()) % (24 *60 * 60)) + altzone + t = (24 * 60 * 60) - (int(time()) % (24 * 60 * 60)) + altzone self.logInfo("You've reach your daily download transfer") - self.retry(10, 10 if t < 1 else None, "Try tomorrow again") #@NOTE: check t in case of not synchronised clock + self.retry(10, 10 if t < 1 else None, _("Try tomorrow again")) #@NOTE: check t in case of not synchronised clock else: self.wait(int(jsvars['timeToDownload']) - int(time())) @@ -59,18 +61,20 @@ class RapiduNet(SimpleHoster): for _i in xrange(10): challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) - jsvars = self.getJsonResponse("https://rapidu.net/ajax.php?a=getCheckCaptcha", - {'_go' : None, - 'captcha1': challenge, - 'captcha2': response, - 'fileId' : self.info['ID']}) + jsvars = self.getJsonResponse("https://rapidu.net/ajax.php", + get={'a': "getCheckCaptcha"}, + post={'_go' : "", + 'captcha1': challenge, + 'captcha2': response, + 'fileId' : self.info['ID']}, + decode=True) if jsvars['message'] == 'success': self.download(jsvars['url']) break - def getJsonResponse(self, url, post_data): - res = self.load(url, post=post_data, decode=True) + def getJsonResponse(self, *args, **kwargs): + res = self.load(*args, **kwargs) if not res.startswith('{'): self.retry() |