summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/RapiduNet.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-05 23:01:13 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-05 23:01:13 +0100
commitd42203e97a294cdf06b281b8ab001b2d6247fa49 (patch)
tree05f577b0237f7794125d9563ae7d52e198e20ffb /module/plugins/hoster/RapiduNet.py
parent[FileSharkPl] Recovered needed behaviour (diff)
downloadpyload-d42203e97a294cdf06b281b8ab001b2d6247fa49.tar.xz
[RapiduNet] Cleanup
Diffstat (limited to 'module/plugins/hoster/RapiduNet.py')
-rw-r--r--module/plugins/hoster/RapiduNet.py89
1 files changed, 37 insertions, 52 deletions
diff --git a/module/plugins/hoster/RapiduNet.py b/module/plugins/hoster/RapiduNet.py
index 624c5844b..e14b18a4f 100644
--- a/module/plugins/hoster/RapiduNet.py
+++ b/module/plugins/hoster/RapiduNet.py
@@ -3,94 +3,79 @@
import re
from pycurl import HTTPHEADER
-from module.common.json_layer import json_loads
from time import time, altzone
+from module.common.json_layer import json_loads
from module.plugins.internal.CaptchaService import ReCaptcha
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class RapiduNet(SimpleHoster):
- __name__ = "RapiduNet"
- __type__ = "hoster"
- __version__ = "0.01"
- __pattern__ = r'https?://(?:www\.)?rapidu\.net/(?P<fileID>\d{10})(/|/.*)?'
+ __name__ = "RapiduNet"
+ __type__ = "hoster"
+ __version__ = "0.02"
+
+ __pattern__ = r'https?://(?:www\.)?rapidu\.net/(?P<ID>\d{10})'
+
__description__ = """Rapidu.net hoster plugin"""
- __authors__ = [("prOq", None)]
+ __license__ = "GPLv3"
+ __authors__ = [("prOq", None)]
+ COOKIES = [("rapidu.net", "rapidu_lang", "en")]
+
FILE_INFO_PATTERN = r'<h1 title="(?P<N>.*)">.*</h1>\s*<small>(?P<S>\d+(\.\d+)?)\s(?P<U>\w+)</small>'
+ OFFLINE_PATTERN = r'404 - File not found'
- OFFLINE_PATTERN = '404 - (File not found|Nie znaleziono pliku)'
- ERROR_PATTERN = '<div class="error">'
+ ERROR_PATTERN = r'<div class="error">'
RECAPTCHA_KEY = r'6Ld12ewSAAAAAHoE6WVP_pSfCdJcBQScVweQh8Io'
- fileID = ""
-
def setup(self):
self.resumeDownload = True
- self.multiDL = True
-
- if self.premium:
- self.limitDL = -1
- else:
- self.limitDL = 2
-
-
- def process(self, pyfile):
- m = re.match(self.__pattern__, self.pyfile.url)
- if m:
- self.fileID = m.group('fileID')
- else:
- self.fail("URL mismatch")
-
- self.handleFree()
+ self.multiDL = True
+ self.limitDL = 0 if self.premium else 2
def handleFree(self):
- self.html = self.load(self.pyfile.url, decode=True)
-
- if re.search(self.ERROR_PATTERN, self.html):
- self.fail("An error occured on hoster")
-
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?a=getLoadTimeToDownload", {'_go': None})
- if str(jsvars['timeToDownload']) is "stop":
- t = (24 *60 * 60) - (int(time()) % (24 *60 * 60)) + altzone
- t = 10 if t < 1 else None # in case of not synchronised clock
- self.logInfo("You've reach your daily download transfer")
- self.retry(10, t, "Try tomorrow again")
- else:
- self.wait((int(jsvars['timeToDownload'])-int(time())))
+ if str(jsvars['timeToDownload']) is "stop":
+ t = (24 * 60 * 60) - (int(time()) % (24 *60 * 60)) + altzone
- recaptcha = ReCaptcha(self)
+ self.logInfo("You've reach your daily download transfer")
- for _ in xrange(10):
- challenge, code = recaptcha.challenge(self.RECAPTCHA_KEY)
+ self.retry(10, 10 if t < 1 else None, "Try tomorrow again") #@NOTE: check t in case of not synchronised clock
- self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"])
- jsvars = self.getJsonResponse("https://rapidu.net/ajax.php?a=getCheckCaptcha", {
- "_go": None,
- "captcha1": challenge,
- "captcha2": code,
- "fileId": self.fileID
- })
+ else:
+ self.wait(int(jsvars['timeToDownload']) - int(time()))
- if jsvars['message'] == 'success':
- self.download(jsvars['url'])
- break
+ recaptcha = ReCaptcha(self)
+
+ for _i in xrange(10):
+ challenge, code = recaptcha.challenge(self.RECAPTCHA_KEY)
+
+ jsvars = self.getJsonResponse("https://rapidu.net/ajax.php?a=getCheckCaptcha",
+ {'_go' : None,
+ 'captcha1': challenge,
+ 'captcha2': code,
+ 'fileId' : self.info['ID']})
+ if jsvars['message'] == 'success':
+ self.download(jsvars['url'])
+ break
def getJsonResponse(self, url, post_data):
response = self.load(url, post=post_data, decode=True)
if not response.startswith('{'):
self.retry()
+
self.logDebug(url, response)
+
return json_loads(response)