summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/plugins/accounts/RapidgatorNet.py3
-rw-r--r--module/plugins/hoster/RapidgatorNet.py86
2 files changed, 48 insertions, 41 deletions
diff --git a/module/plugins/accounts/RapidgatorNet.py b/module/plugins/accounts/RapidgatorNet.py
index 126271468..74825a0f9 100644
--- a/module/plugins/accounts/RapidgatorNet.py
+++ b/module/plugins/accounts/RapidgatorNet.py
@@ -24,7 +24,7 @@ from module.common.json_layer import json_loads
class RapidgatorNet(Account):
__name__ = "RapidgatorNet"
- __version__ = "0.02"
+ __version__ = "0.03"
__type__ = "account"
__description__ = """rapidgator.net account plugin"""
__author_name__ = ("zoidberg")
@@ -57,7 +57,6 @@ class RapidgatorNet(Account):
def login(self, user, data, req):
try:
- self.logDebug("DATA", user, data)
json = req.load('%s/login' % self.API_URL,
post = {"username": user,
"password": data['password']})
diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py
index 47ab662d9..ad23b5a33 100644
--- a/module/plugins/hoster/RapidgatorNet.py
+++ b/module/plugins/hoster/RapidgatorNet.py
@@ -23,77 +23,85 @@ from random import random
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia, AdsCaptcha
from module.common.json_layer import json_loads
+from module.network.HTTPRequest import BadHeader
class RapidgatorNet(SimpleHoster):
__name__ = "RapidgatorNet"
__type__ = "hoster"
__pattern__ = r"http://(?:www\.)?(rapidgator.net)/file/(\d+)"
- __version__ = "0.09"
+ __version__ = "0.10"
__description__ = """rapidgator.net"""
__author_name__ = ("zoidberg","chrox")
-
+
API_URL = 'http://rapidgator.net/api/file'
-
+
FILE_INFO_PATTERN = r'Downloading:(\s*<[^>]*>)*\s*(?P<N>.*?)(\s*<[^>]*>)*\s*File size:\s*<strong>(?P<S>.*?)</strong>'
FILE_OFFLINE_PATTERN = r'<title>File not found</title>'
-
- JSVARS_PATTERN = r"\s+var\s*(startTimerUrl|getDownloadUrl|captchaUrl|fid|secs)\s*=\s*'?(.*?)'?;"
+
+ JSVARS_PATTERN = r"\s+var\s*(startTimerUrl|getDownloadUrl|captchaUrl|fid|secs)\s*=\s*'?(.*?)'?;"
DOWNLOAD_LINK_PATTERN = r"location.href = '(.*?)'"
RECAPTCHA_KEY_PATTERN = r'"http://api.recaptcha.net/challenge?k=(.*?)"'
ADSCAPTCHA_SRC_PATTERN = r'(http://api.adscaptcha.com/Get.aspx[^"\']*)'
SOLVEMEDIA_PATTERN = r'http:\/\/api\.solvemedia\.com\/papi\/challenge\.script\?k=(.*?)"'
-
+
def getAPIResponse(self, cmd):
- json = self.load('%s/%s' % (self.API_URL, cmd),
- get = {'sid': self.account.getAccountData(self.user).get('SID'),
- 'url': self.pyfile.url})
- self.logDebug('API:%s' % cmd, json)
- json = json_loads(json)
-
- status = json['response_status']
+ try:
+ json = self.load('%s/%s' % (self.API_URL, cmd),
+ get = {'sid': self.account.getAccountData(self.user).get('SID'),
+ 'url': self.pyfile.url}, decode = True)
+ self.logDebug('API:%s' % cmd, json)
+ json = json_loads(json)
+ status = json['response_status']
+ msg = json['response_details']
+ except BadHeader, e:
+ self.logError('API:%s' % cmd, e)
+ status = e.code
+ msg = e
+
if status == 200:
return json['response']
elif status == 401:
- self.account.relogin(self.user)
- self.retry()
+ self.retry()
elif status == 423:
self.account.empty(self.user)
self.retry()
else:
- self.fail(json['response_details'])
-
+ self.fail(msg)
+
def handlePremium(self):
+ self.account.relogin(self.user)
self.api_data = self.getAPIResponse('info')
+ self.api_data['md5'] = self.api_data['hash']
self.pyfile.name = self.api_data['filename']
- self.pyfile.size = self.api_data['size']
+ self.pyfile.size = self.api_data['size']
url = self.getAPIResponse('download')['url']
- self.download(url)
-
+ self.download(url)
+
def handleFree(self):
if "You can download files up to 500 MB in free mode" in self.html \
or "This file can be downloaded by premium only" in self.html:
self.fail("Premium account needed for download")
-
- self.checkWait()
-
+
+ self.checkWait()
+
jsvars = dict(re.findall(self.JSVARS_PATTERN, self.html))
self.logDebug(jsvars)
-
+
self.req.http.lastURL = self.pyfile.url
self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"])
-
- url = "http://rapidgator.net%s?fid=%s" % (jsvars.get('startTimerUrl', '/download/AjaxStartTimer'), jsvars["fid"])
+
+ url = "http://rapidgator.net%s?fid=%s" % (jsvars.get('startTimerUrl', '/download/AjaxStartTimer'), jsvars["fid"])
jsvars.update(self.getJsonResponse(url))
-
+
self.setWait(int(jsvars.get('secs', 30)) + 1, False)
self.wait()
-
+
url = "http://rapidgator.net%s?sid=%s" % (jsvars.get('getDownloadUrl', '/download/AjaxGetDownload'), jsvars["sid"])
jsvars.update(self.getJsonResponse(url))
-
+
self.req.http.lastURL = self.pyfile.url
self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With:"])
-
+
url = "http://rapidgator.net%s" % jsvars.get('captchaUrl', '/download/captcha')
self.html = self.load(url)
found = re.search(self.ADSCAPTCHA_SRC_PATTERN, self.html)
@@ -105,7 +113,7 @@ class RapidgatorNet(SimpleHoster):
if found:
captcha_key = found.group(1)
captcha = ReCaptcha(self)
-
+
else:
found = re.search(self.SOLVEMEDIA_PATTERN, self.html)
if found:
@@ -116,8 +124,8 @@ class RapidgatorNet(SimpleHoster):
if captcha.__class__.__name__ == "SolveMedia":
captcha_prov = "adcopy"
else:
- captcha_prov = captcha.__class__.__name__.lower()
-
+ captcha_prov = captcha.__class__.__name__.lower()
+
for i in range(5):
self.checkWait()
captcha_challenge, captcha_response = captcha.challenge(captcha_key)
@@ -135,14 +143,14 @@ class RapidgatorNet(SimpleHoster):
break
else:
self.fail("No valid captcha solution received")
-
+
found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html)
if not found:
self.parseError("download link")
download_url = found.group(1)
self.logDebug(download_url)
self.download(download_url)
-
+
def checkWait(self):
found = re.search(r"(?:Delay between downloads must be not less than|Try again in)\s*(\d+)\s*(hour|min)", self.html)
if found:
@@ -153,17 +161,17 @@ class RapidgatorNet(SimpleHoster):
wait_time = 60
else:
return
-
+
self.logDebug("Waiting %d minutes" % wait_time)
self.setWait(wait_time * 60, True)
self.wait()
self.retry(max_tries = 24)
-
+
def getJsonResponse(self, url):
response = self.load(url, decode = True)
if not response.startswith('{'):
- self.retry()
+ self.retry()
self.logDebug(url, response)
- return json_loads(response)
+ return json_loads(response)
getInfo = create_getInfo(RapidgatorNet) \ No newline at end of file