diff options
author | z00nx <z00nx0@gmail.com> | 2013-01-10 19:43:37 +0100 |
---|---|---|
committer | z00nx <z00nx0@gmail.com> | 2013-01-10 19:43:37 +0100 |
commit | 6ab589a3c1ecef5895d9a28d0389ecb721a32387 (patch) | |
tree | 3b4c81c98d25a7b31d86263a2fe02118c833e474 /module | |
parent | Alldebdrid update (diff) | |
download | pyload-6ab589a3c1ecef5895d9a28d0389ecb721a32387.tar.xz |
Updated LetitbitNet plugin
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/hoster/LetitbitNet.py | 91 |
1 files changed, 53 insertions, 38 deletions
diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 88e708bf5..19c164710 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -17,9 +17,10 @@ """ import re -from random import random from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.common.json_layer import json_loads +from module.plugins.ReCaptcha import ReCaptcha + class LetitbitNet(SimpleHoster): __name__ = "LetitbitNet" @@ -27,30 +28,33 @@ class LetitbitNet(SimpleHoster): __pattern__ = r"http://(?:\w*\.)*(letitbit|shareflare).net/download/.*" __version__ = "0.19" __description__ = """letitbit.net""" - __author_name__ = ("zoidberg") - __author_mail__ = ("zoidberg@mujmail.cz") + __author_name__ = ("zoidberg", "z00nx") + __author_mail__ = ("zoidberg@mujmail.cz", "z00nx0@gmail.com") CHECK_URL_PATTERN = r"ajax_check_url\s*=\s*'((http://[^/]+)[^']+)';" SECONDS_PATTERN = r"seconds\s*=\s*(\d+);" - - FILE_INFO_PATTERN = r'<h1[^>]*>File:.*?<span>(?P<N>[^<]+)</span>.*?\[<span>(?P<S>[^<]+)</span>]</h1>' + CAPTCHA_CONTROL_FIELD = r"recaptcha_control_field\s=\s'(?P<value>[^']+)'" + FILE_INFO_PATTERN = r'<span[^>]*>File:.*?<span[^>]*>(?P<N>[^&]+).*</span>.*?\[(?P<S>[^\]]+)\]</span>' FILE_OFFLINE_PATTERN = r'>File not found<' - + DOMAIN = "http://letitbit.net" FILE_URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "letitbit.net")] - + RECAPTCHA_KEY = "6Lc9zdMSAAAAAF-7s2wuQ-036pLRbM0p8dDaQdAM" + def setup(self): - self.resumeDownload = self.multiDL = True + self.resumeDownload = True + #TODO confirm that resume works def handleFree(self): action, inputs = self.parseHtmlForm('id="ifree_form"') - if not action: self.parseError("page 1 / ifree_form") + if not action: + self.parseError("page 1 / ifree_form") self.pyfile.size = float(inputs['sssize']) - #self.logDebug(action, inputs) + self.logDebug(action, inputs) inputs['desc'] = "" - self.html = self.load(self.DOMAIN + action, post = inputs, cookies = True) - + self.html = self.load(self.DOMAIN + action, post=inputs, cookies=True) + """ action, inputs = self.parseHtmlForm('id="d3_form"') if not action: self.parseError("page 2 / d3_form") @@ -68,35 +72,46 @@ class LetitbitNet(SimpleHoster): self.logError(e) self.parseError("page 3 / js") """ - - found = re.search(self.SECONDS_PATTERN, self.html) + + found = re.search(self.SECONDS_PATTERN, self.html) seconds = int(found.group(1)) if found else 60 - self.setWait(seconds+1) + self.logDebug("Seconds found", seconds) + found = re.search(self.CAPTCHA_CONTROL_FIELD, self.html) + recaptcha_control_field = found.group(1) + self.logDebug("ReCaptcha control field found", recaptcha_control_field) + self.setWait(seconds + 1) self.wait() - - response = self.load("%s/ajax/download3.php" % self.DOMAIN, post = " ", cookies = True) - if response != '1': self.parseError('Unknown response - ajax_check_url') - - for i in range(5): - captcha = self.decryptCaptcha('%s/captcha_new.php?rand=%d' % (self.DOMAIN, random() * 100000), cookies = True) - response = self.load('%s/ajax/check_captcha.php' % self.DOMAIN, post = {"code": captcha}, cookies = True) - self.logDebug(response) - if not response: - self.invalidCaptcha() - elif response.startswith('['): - urls = json_loads(response) - break - elif response.startswith('http://'): - urls = [response] - break - else: - self.parseError("Unknown response - captcha check") - + + response = self.load("%s/ajax/download3.php" % self.DOMAIN, post=" ", cookies=True) + if response != '1': + self.parseError('Unknown response - ajax_check_url') + self.logDebug(response) + + recaptcha = ReCaptcha(self) + challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) + post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": response, "recaptcha_control_field": recaptcha_control_field} + self.logDebug("Post data to send", post_data) + response = self.load('%s/ajax/check_recaptcha.php' % self.DOMAIN, post=post_data, cookies=True) + self.logDebug(response) + if not response: + self.invalidCaptcha() + if response == "error_free_download_blocked": + self.logInfo("Daily limit reached, waiting 24 hours") + self.setWait(24 * 60 * 60) + self.wait() + if response == "error_wrong_captcha": + self.logInfo("Wrong Captcha") + self.invalidCaptcha() + self.retry() + elif response.startswith('['): + urls = json_loads(response) + elif response.startswith('http://'): + urls = [response] else: - self.fail("No valid captcha solution received") - + self.parseError("Unknown response - captcha check") + self.correctCaptcha() - + for download_url in urls: try: self.logDebug("Download URL", download_url) @@ -107,4 +122,4 @@ class LetitbitNet(SimpleHoster): else: self.fail("Download did not finish correctly") -getInfo = create_getInfo(LetitbitNet)
\ No newline at end of file +getInfo = create_getInfo(LetitbitNet) |