summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-03-10 03:01:47 +0100
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-03-10 03:01:47 +0100
commitcfd5dcb231d55478442c7b80517064b377eda43d (patch)
tree88530adc2a3e05ae7d10f6dbaa44377e6dc56444 /module
parentSpare code cosmetics (diff)
downloadpyload-cfd5dcb231d55478442c7b80517064b377eda43d.tar.xz
[RapidgatorNet] Fix https://github.com/pyload/pyload/issues/1237
Diffstat (limited to 'module')
-rw-r--r--module/plugins/hoster/RapidgatorNet.py36
-rw-r--r--module/plugins/internal/SimpleHoster.py23
2 files changed, 31 insertions, 28 deletions
diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py
index 7ec843646..761d7ff99 100644
--- a/module/plugins/hoster/RapidgatorNet.py
+++ b/module/plugins/hoster/RapidgatorNet.py
@@ -7,13 +7,13 @@ from pycurl import HTTPHEADER
from module.common.json_layer import json_loads
from module.network.HTTPRequest import BadHeader
from module.plugins.internal.CaptchaService import AdsCaptcha, ReCaptcha, SolveMedia
-from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, secondsToMidnight
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class RapidgatorNet(SimpleHoster):
__name__ = "RapidgatorNet"
__type__ = "hoster"
- __version__ = "0.32"
+ __version__ = "0.33"
__pattern__ = r'http://(?:www\.)?(rapidgator\.net|rg\.to)/file/\w+'
@@ -36,7 +36,7 @@ class RapidgatorNet(SimpleHoster):
JSVARS_PATTERN = r'\s+var\s*(startTimerUrl|getDownloadUrl|captchaUrl|fid|secs)\s*=\s*\'?(.*?)\'?;'
PREMIUM_ONLY_PATTERN = r'You can download files up to|This file can be downloaded by premium only<'
- ERROR_PATTERN = r'You have reached your (daily|hourly) downloads limit'
+ ERROR_PATTERN = r'You have reached your (?:daily|hourly) downloads limit'
WAIT_PATTERN = r'(Delay between downloads must be not less than|Try again in).+'
LINK_FREE_PATTERN = r'return \'(http://\w+.rapidgator.net/.*)\';'
@@ -125,8 +125,12 @@ class RapidgatorNet(SimpleHoster):
self.link = m.group(1)
break
else:
- captcha, captcha_key = self.handleCaptcha()
- response, challenge = captcha.challenge(captcha_key)
+ captcha = self.handleCaptcha()
+
+ if not captcha:
+ self.error(_("Captcha pattern not found"))
+
+ response, challenge = captcha.challenge()
self.html = self.load(url, post={'DownloadCaptchaForm[captcha]': "",
'adcopy_challenge' : challenge,
@@ -141,24 +145,10 @@ class RapidgatorNet(SimpleHoster):
def handleCaptcha(self):
- m = re.search(self.ADSCAPTCHA_PATTERN, self.html)
- if m:
- captcha_key = m.group(1)
- captcha = AdsCaptcha(self)
- else:
- m = re.search(self.RECAPTCHA_PATTERN, self.html)
- if m:
- captcha_key = m.group(1)
- captcha = ReCaptcha(self)
- else:
- m = re.search(self.SOLVEMEDIA_PATTERN, self.html)
- if m:
- captcha_key = m.group(1)
- captcha = SolveMedia(self)
- else:
- self.error(_("Captcha"))
-
- return captcha, captcha_key
+ for klass in (AdsCaptcha, ReCaptcha, SolveMedia):
+ inst = klass(self)
+ if inst.detect_key():
+ return inst
def getJsonResponse(self, url):
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index df6e78485..2754b0b18 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -237,7 +237,7 @@ def secondsToMidnight(gmt=0):
if hasattr(td, 'total_seconds'):
res = td.total_seconds()
- else: #@NOTE: work-around for python 2.5 and 2.6 missing timedelta.total_seconds
+ else: #: work-around for python 2.5 and 2.6 missing timedelta.total_seconds
res = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
return int(res)
@@ -246,7 +246,7 @@ def secondsToMidnight(gmt=0):
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.16"
+ __version__ = "1.17"
__pattern__ = r'^unmatchable$'
@@ -537,8 +537,22 @@ class SimpleHoster(Hoster):
elif hasattr(self, 'ERROR_PATTERN'):
m = re.search(self.ERROR_PATTERN, self.html)
if m:
- errmsg = self.info['error'] = m.group(1)
- self.error(errmsg)
+ errmsg
+ try:
+ errmsg = m.group(1)
+ except Exception:
+ errmsg = m.group(0)
+
+ self.info['error'] = errmsg
+
+ if "hour" in errmsg
+ self.wait(secondsToMidnight(gmt=2), True)
+
+ elif re.search("da(il)?y|today", errmsg):
+ self.wait(1 * 60 * 60, True)
+
+ else:
+ self.error(errmsg)
elif hasattr(self, 'WAIT_PATTERN'):
m = re.search(self.WAIT_PATTERN, self.html)
@@ -546,7 +560,6 @@ class SimpleHoster(Hoster):
wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1}[u.lower()] for v, u in
re.findall(r'(\d+)\s*(hr|hour|min|sec)', m.group(0), re.I))
self.wait(wait_time, wait_time > 300)
- return
self.info.pop('error', None)