summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/TurbobitNet.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/TurbobitNet.py')
-rw-r--r--module/plugins/hoster/TurbobitNet.py97
1 files changed, 49 insertions, 48 deletions
diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py
index d323a214b..d20d1cadd 100644
--- a/module/plugins/hoster/TurbobitNet.py
+++ b/module/plugins/hoster/TurbobitNet.py
@@ -10,13 +10,14 @@ import urllib
from Crypto.Cipher import ARC4
from module.plugins.captcha.ReCaptcha import ReCaptcha
-from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp
+from module.plugins.internal.Plugin import timestamp
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class TurbobitNet(SimpleHoster):
__name__ = "TurbobitNet"
__type__ = "hoster"
- __version__ = "0.21"
+ __version__ = "0.22"
__status__ = "testing"
__pattern__ = r'http://(?:www\.)?turbobit\.net/(?:download/free/)?(?P<ID>\w+)'
@@ -56,64 +57,64 @@ class TurbobitNet(SimpleHoster):
self.req.http.c.setopt(pycurl.HTTPHEADER, ["X-Requested-With:"])
m = re.search(self.LINK_FREE_PATTERN, self.html)
- if m:
+ if m is not None:
self.link = m.group(1)
def solve_captcha(self):
- for _i in xrange(5):
- m = re.search(self.LIMIT_WAIT_PATTERN, self.html)
- if m:
- wait_time = int(m.group(1))
- self.wait(wait_time, wait_time > 60)
- self.retry()
+ m = re.search(self.LIMIT_WAIT_PATTERN, self.html)
+ if m is not None:
+ wait_time = int(m.group(1))
+ self.wait(wait_time, wait_time > 60)
+ self.retry()
- action, inputs = self.parse_html_form("action='#'")
- if not inputs:
- self.error(_("Captcha form not found"))
- self.log_debug(inputs)
+ action, inputs = self.parse_html_form("action='#'")
+ if not inputs:
+ self.error(_("Captcha form not found"))
- if inputs['captcha_type'] == "recaptcha":
- recaptcha = ReCaptcha(self)
- inputs['recaptcha_response_field'], inputs['recaptcha_challenge_field'] = recaptcha.challenge()
- else:
- m = re.search(self.CAPTCHA_PATTERN, self.html)
- if m is None:
- self.error(_("captcha"))
- captcha_url = m.group(1)
- inputs['captcha_response'] = self.captcha.decrypt(captcha_url)
+ self.log_debug(inputs)
- self.log_debug(inputs)
- self.html = self.load(self.url, post=inputs)
+ if inputs['captcha_type'] == "recaptcha":
+ recaptcha = ReCaptcha(self)
+ inputs['recaptcha_response_field'], inputs['recaptcha_challenge_field'] = recaptcha.challenge()
+ else:
+ m = re.search(self.CAPTCHA_PATTERN, self.html)
+ if m is None:
+ self.error(_("Captcha pattern not found"))
+ captcha_url = m.group(1)
+ inputs['captcha_response'] = self.captcha.decrypt(captcha_url)
- if '<div class="captcha-error">Incorrect, try again!<' in self.html:
- self.captcha.invalid()
- else:
- self.captcha.correct()
- break
+ self.log_debug(inputs)
+
+ self.html = self.load(self.url, post=inputs)
+
+ if '<div class="captcha-error">Incorrect, try again' in self.html:
+ self.retry_captcha()
else:
- self.fail(_("Invalid captcha"))
+ self.captcha.correct()
def get_rt_update(self):
rtUpdate = self.retrieve("rtUpdate")
- if not rtUpdate:
- if self.retrieve("version") is not self.__version__ \
- or int(self.retrieve("timestamp", 0)) + 86400000 < timestamp():
- #: that's right, we are even using jdownloader updates
- rtUpdate = self.load("http://update0.jdownloader.org/pluginstuff/tbupdate.js")
- rtUpdate = self.decrypt(rtUpdate.splitlines()[1])
- #: But we still need to fix the syntax to work with other engines than rhino
- rtUpdate = re.sub(r'for each\(var (\w+) in(\[[^\]]+\])\)\{',
- r'zza=\2;for(var zzi=0;zzi<zza.length;zzi++){\1=zza[zzi];', rtUpdate)
- rtUpdate = re.sub(r"for\((\w+)=", r"for(var \1=", rtUpdate)
-
- self.store("rtUpdate", rtUpdate)
- self.store("timestamp", timestamp())
- self.store("version", self.__version__)
- else:
- self.log_error(_("Unable to download, wait for update..."))
- self.temp_offline()
+ if rtUpdate:
+ return rtUpdate
+
+ if self.retrieve("version") is not self.__version__ or \
+ int(self.retrieve("timestamp", 0)) + 86400000 < timestamp():
+ #: that's right, we are even using jdownloader updates
+ rtUpdate = self.load("http://update0.jdownloader.org/pluginstuff/tbupdate.js")
+ rtUpdate = self.decrypt(rtUpdate.splitlines()[1])
+ #: But we still need to fix the syntax to work with other engines than rhino
+ rtUpdate = re.sub(r'for each\(var (\w+) in(\[[^\]]+\])\)\{',
+ r'zza=\2;for(var zzi=0;zzi<zza.length;zzi++){\1=zza[zzi];', rtUpdate)
+ rtUpdate = re.sub(r"for\((\w+)=", r"for(var \1=", rtUpdate)
+
+ self.store("rtUpdate", rtUpdate)
+ self.store("timestamp", timestamp())
+ self.store("version", self.__version__)
+ else:
+ self.log_error(_("Unable to download, wait for update..."))
+ self.temp_offline()
return rtUpdate
@@ -122,7 +123,7 @@ class TurbobitNet(SimpleHoster):
self.req.http.lastURL = self.url
m = re.search("(/\w+/timeout\.js\?\w+=)([^\"\'<>]+)", self.html)
- if m:
+ if m is not None:
url = "http://turbobit.net%s%s" % m.groups()
else:
url = "http://turbobit.net/files/timeout.js?ver=%s" % "".join(random.choice('0123456789ABCDEF') for _i in xrange(32))