diff options
Diffstat (limited to 'module/plugins/hoster')
77 files changed, 442 insertions, 571 deletions
diff --git a/module/plugins/hoster/AndroidfilehostCom.py b/module/plugins/hoster/AndroidfilehostCom.py index 3fb77f83e..38f3b8392 100644 --- a/module/plugins/hoster/AndroidfilehostCom.py +++ b/module/plugins/hoster/AndroidfilehostCom.py @@ -42,7 +42,7 @@ class AndroidfilehostCom(SimpleHoster): self.log_debug("Waiting time: %s seconds" % wait.group(1)) fid = re.search(r'id="fid" value="(\d+)" />', self.html).group(1) - self.log_debug("fid: %s" % fid) + self.log_debug("FID: %s" % fid) html = self.load("https://www.androidfilehost.com/libs/otf/mirrors.otf.php", post={'submit': 'submit', diff --git a/module/plugins/hoster/BezvadataCz.py b/module/plugins/hoster/BezvadataCz.py index 547be68fb..204c981c6 100644 --- a/module/plugins/hoster/BezvadataCz.py +++ b/module/plugins/hoster/BezvadataCz.py @@ -39,24 +39,16 @@ class BezvadataCz(SimpleHoster): #: Captcha form self.html = self.load(url) self.check_errors() - for _i in xrange(5): - action, inputs = self.parse_html_form('frm-stahnoutFreeForm') - if not inputs: - self.error(_("FreeForm")) - - m = re.search(r'<img src="data:image/png;base64,(.*?)"', self.html) - if m is None: - self.error(_("Wrong captcha image")) - - inputs['captcha'] = self.captcha.decrypt_image(m.group(1).decode('base64'), input_type='png') - - if '<img src="data:image/png;base64' in self.html: - self.captcha.invalid() - else: - self.captcha.correct() - break - else: - self.fail(_("No valid captcha code entered")) + + action, inputs = self.parse_html_form('frm-stahnoutFreeForm') + if not inputs: + self.error(_("FreeForm")) + + m = re.search(r'<img src="data:image/png;base64,(.*?)"', self.html) + if m is None: + self.retry_captcha() + + inputs['captcha'] = self.captcha.decrypt_image(m.group(1).decode('base64'), input_type='png') #: Download url self.html = self.load("http://bezvadata.cz%s" % action, post=inputs) diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index cea78088e..e426de092 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -114,16 +114,14 @@ class BitshareCom(SimpleHoster): self.log_debug("File is captcha protected") recaptcha = ReCaptcha(self) - #: Try up to 3 times - for i in xrange(3): - response, challenge = recaptcha.challenge() - res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={'request' : "validateCaptcha", - 'ajaxid' : self.ajaxid, - 'recaptcha_challenge_field': challenge, - 'recaptcha_response_field' : response}) - if self.handle_captcha_errors(res): - break + response, challenge = recaptcha.challenge() + res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", + post={'request' : "validateCaptcha", + 'ajaxid' : self.ajaxid, + 'recaptcha_challenge_field': challenge, + 'recaptcha_response_field' : response}) + + self.handle_captcha_errors(res) #: Get download URL self.log_debug("Getting download url") @@ -141,6 +139,7 @@ class BitshareCom(SimpleHoster): self.log_debug("Checking response [%s]" % res) if "ERROR:Session timed out" in res: self.retry() + elif "ERROR" in res: msg = res.split(separator)[-1] self.fail(msg) @@ -150,11 +149,12 @@ class BitshareCom(SimpleHoster): self.log_debug("Result of captcha resolving [%s]" % res) if "SUCCESS" in res: self.captcha.correct() - return True + elif "ERROR:SESSION ERROR" in res: self.retry() - self.captcha.invalid() + else: + self.retry_captcha() getInfo = create_getInfo(BitshareCom) diff --git a/module/plugins/hoster/CatShareNet.py b/module/plugins/hoster/CatShareNet.py index 5b7d61e05..c2b8d9257 100644 --- a/module/plugins/hoster/CatShareNet.py +++ b/module/plugins/hoster/CatShareNet.py @@ -46,7 +46,7 @@ class CatShareNet(SimpleHoster): 'recaptcha_response_field' : response}) m = re.search(self.LINK_FREE_PATTERN, self.html) - if m: + if m is not None: self.link = m.group(1) diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py index 2ed140b9c..70f2be6fb 100644 --- a/module/plugins/hoster/CrockoCom.py +++ b/module/plugins/hoster/CrockoCom.py @@ -39,7 +39,7 @@ class CrockoCom(SimpleHoster): for _i in xrange(5): m = re.search(self.CAPTCHA_PATTERN, self.html) - if m: + if m is not None: url = urlparse.urljoin("http://crocko.com/", m.group(1)) self.wait(m.group(2)) self.html = self.load(url) @@ -54,16 +54,11 @@ class CrockoCom(SimpleHoster): inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) recaptcha = ReCaptcha(self) - for _i in xrange(5): - inputs['recaptcha_response_field'], inputs['recaptcha_challenge_field'] = recaptcha.challenge() - self.download(action, post=inputs) + inputs['recaptcha_response_field'], inputs['recaptcha_challenge_field'] = recaptcha.challenge() + self.download(action, post=inputs) - if self.check_file({'captcha': recaptcha.KEY_AJAX_PATTERN}): - self.captcha.invalid() - else: - break - else: - self.fail(_("No valid captcha solution received")) + if self.check_file({'captcha': recaptcha.KEY_AJAX_PATTERN}): + self.retry_captcha() getInfo = create_getInfo(CrockoCom) diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index eeba9d86d..ad2559e13 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -67,7 +67,6 @@ class CzshareCom(SimpleHoster): def handle_premium(self, pyfile): - #: Parse download link try: form = re.search(self.PREMIUM_FORM_PATTERN, self.html, re.S).group(1) inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) @@ -106,21 +105,17 @@ class CzshareCom(SimpleHoster): #: Get and decrypt captcha captcha_url = 'http://sdilej.cz/captcha.php' - for _i in xrange(5): - inputs['captchastring2'] = self.captcha.decrypt(captcha_url) - self.html = self.load(parsed_url, post=inputs) + inputs['captchastring2'] = self.captcha.decrypt(captcha_url) + self.html = self.load(parsed_url, post=inputs) - if u"<li>Zadaný ověřovací kód nesouhlasí!</li>" in self.html: - self.captcha.invalid() + if u"<li>Zadaný ověřovací kód nesouhlasí!</li>" in self.html: + self.retry_captcha() - elif re.search(self.MULTIDL_PATTERN, self.html): - self.wait(5 * 60, 12, _("Download limit reached")) + elif re.search(self.MULTIDL_PATTERN, self.html): + self.wait(5 * 60, 12, _("Download limit reached")) - else: - self.captcha.correct() - break else: - self.fail(_("No valid captcha code entered")) + self.captcha.correct() m = re.search("countdown_number = (\d+);", self.html) self.set_wait(int(m.group(1)) if m else 50) @@ -156,8 +151,7 @@ class CzshareCom(SimpleHoster): self.wait(5 * 60, 12, _("Download limit reached")) elif check == "captcha": - self.captcha.invalid() - self.retry() + self.retry_captcha() return super(CzshareCom, self).check_download() diff --git a/module/plugins/hoster/DataportCz.py b/module/plugins/hoster/DataportCz.py index 2b30df059..fe304fdea 100644 --- a/module/plugins/hoster/DataportCz.py +++ b/module/plugins/hoster/DataportCz.py @@ -28,32 +28,26 @@ class DataportCz(SimpleHoster): def handle_free(self, pyfile): captchas = {'1': "jkeG", '2': "hMJQ", '3': "vmEK", '4': "ePQM", '5': "blBd"} - for _i in xrange(60): - action, inputs = self.parse_html_form('free_download_form') - self.log_debug(action, inputs) - if not action or not inputs: - self.error(_("free_download_form")) - - if "captchaId" in inputs and inputs['captchaId'] in captchas: - inputs['captchaCode'] = captchas[inputs['captchaId']] - else: - self.error(_("captcha")) - - self.download("http://www.dataport.cz%s" % action, post=inputs) - - check = self.check_file({'captcha': 'alert("\u0160patn\u011b opsan\u00fd k\u00f3d z obr\u00e1zu");', - 'slot' : 'alert("Je n\u00e1m l\u00edto, ale moment\u00e1ln\u011b nejsou'}) - if check == "captcha": - self.error(_("invalid captcha")) - - elif check == "slot": - self.log_debug("No free slots - wait 60s and retry") - self.wait(60, False) - self.html = self.load(pyfile.url) - continue - - else: - break + action, inputs = self.parse_html_form('free_download_form') + self.log_debug(action, inputs) + if not action or not inputs: + self.error(_("free_download_form")) + + if "captchaId" in inputs and inputs['captchaId'] in captchas: + inputs['captchaCode'] = captchas[inputs['captchaId']] + else: + self.error(_("Captcha not found")) + + self.download("http://www.dataport.cz%s" % action, post=inputs) + + check = self.check_file({'captcha': 'alert("\u0160patn\u011b opsan\u00fd k\u00f3d z obr\u00e1zu");', + 'slot' : 'alert("Je n\u00e1m l\u00edto, ale moment\u00e1ln\u011b nejsou'}) + if check == "captcha": + self.retry_captcha() + + elif check == "slot": + self.log_debug("No free slots - wait 60s and retry") + self.retry(wait=60) getInfo = create_getInfo(DataportCz) diff --git a/module/plugins/hoster/DateiTo.py b/module/plugins/hoster/DateiTo.py index d90fc5864..42aed2c77 100644 --- a/module/plugins/hoster/DateiTo.py +++ b/module/plugins/hoster/DateiTo.py @@ -49,7 +49,8 @@ class DateiTo(SimpleHoster): m = re.search(self.DATA_PATTERN, self.html) if m is None: - self.error(_("data")) + self.error(_("Data pattern not found")) + url = 'http://datei.to/' + m.group(1) data = dict(x.split('=') for x in m.group(2).split('&')) diff --git a/module/plugins/hoster/DebridItaliaCom.py b/module/plugins/hoster/DebridItaliaCom.py index 7cf7c4663..ca6603a87 100644 --- a/module/plugins/hoster/DebridItaliaCom.py +++ b/module/plugins/hoster/DebridItaliaCom.py @@ -29,7 +29,7 @@ class DebridItaliaCom(MultiHoster): get={'generate': "on", 'link': pyfile.url, 'p': self.get_password()}) if "ERROR:" not in self.html: - self.link = self.html.strip() + self.link = self.html else: self.info['error'] = re.search(r'ERROR:(.*)', self.html).group(1).strip() diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py index cb9ab5572..b3854f581 100644 --- a/module/plugins/hoster/DepositfilesCom.py +++ b/module/plugins/hoster/DepositfilesCom.py @@ -48,7 +48,7 @@ class DepositfilesCom(SimpleHoster): m = re.search(r"var fid = '(\w+)';", self.html) if m is None: - self.retry(delay=5) + self.retry(wait=5) params = {'fid': m.group(1)} self.log_debug("FID: %s" % params['fid']) @@ -66,7 +66,7 @@ class DepositfilesCom(SimpleHoster): self.html = self.load("https://dfiles.eu/get_file.php", get=params) m = re.search(self.LINK_FREE_PATTERN, self.html) - if m: + if m is not None: self.link = urllib.unquote(m.group(1)) diff --git a/module/plugins/hoster/DlFreeFr.py b/module/plugins/hoster/DlFreeFr.py index f9d427c1b..f77b9596a 100644 --- a/module/plugins/hoster/DlFreeFr.py +++ b/module/plugins/hoster/DlFreeFr.py @@ -100,15 +100,16 @@ class DlFreeFr(SimpleHoster): if headers.get("code") == 302 and "set-cookie" in headers and "location" in headers: m = re.search("(.*?)=(.*?); path=(.*?); domain=(.*)", headers.get("set-cookie")) cj = CookieJar(self.__name__) - if m: + if m is not None: cj.setCookie(m.group(4), m.group(1), m.group(2), m.group(3)) else: self.fail(_("Cookie error")) self.link = headers.get("location") self.req.setCookieJar(cj) + else: - self.fail(_("Invalid response")) + self.fail(_("Bad header")) def get_last_headers(self): diff --git a/module/plugins/hoster/ExashareCom.py b/module/plugins/hoster/ExashareCom.py index 19cd1b46c..c3a4b43dc 100644 --- a/module/plugins/hoster/ExashareCom.py +++ b/module/plugins/hoster/ExashareCom.py @@ -28,11 +28,7 @@ class ExashareCom(XFSHoster): def handle_free(self, pyfile): - m = re.search(self.LINK_FREE_PATTERN, self.html) - if m is None: - self.error(_("Free download link not found")) - else: - self.link = m.group(1) + return super(XFSHoster, self).handle_free(pyfile) getInfo = create_getInfo(ExashareCom) diff --git a/module/plugins/hoster/ExtabitCom.py b/module/plugins/hoster/ExtabitCom.py index 0d5533539..b21db38bb 100644 --- a/module/plugins/hoster/ExtabitCom.py +++ b/module/plugins/hoster/ExtabitCom.py @@ -35,7 +35,7 @@ class ExtabitCom(SimpleHoster): self.fail(_("Only premium users can download this file")) m = re.search(r"Next free download from your ip will be available in <b>(\d+)\s*minutes", self.html) - if m: + if m is not None: self.wait(int(m.group(1)) * 60, True) elif "The daily downloads limit from your IP is exceeded" in self.html: self.log_warning(_("You have reached your daily downloads limit for today")) @@ -46,21 +46,19 @@ class ExtabitCom(SimpleHoster): fileID = m.group('ID') if m else self.info['pattern']['ID'] m = re.search(r'recaptcha/api/challenge\?k=(\w+)', self.html) - if m: + if m is not None: recaptcha = ReCaptcha(self) captcha_key = m.group(1) - for _i in xrange(5): - get_data = {'type': "recaptcha"} - get_data['capture'], get_data['challenge'] = recaptcha.challenge(captcha_key) - res = json_loads(self.load("http://extabit.com/file/%s/" % fileID, get=get_data)) - if "ok" in res: - self.captcha.correct() - break - else: - self.captcha.invalid() + get_data = {'type': "recaptcha"} + get_data['capture'], get_data['challenge'] = recaptcha.challenge(captcha_key) + + res = json_loads(self.load("http://extabit.com/file/%s/" % fileID, get=get_data)) + + if "ok" in res: + self.captcha.correct() else: - self.fail(_("Invalid captcha")) + self.retry_captcha() else: self.error(_("Captcha")) diff --git a/module/plugins/hoster/FastshareCz.py b/module/plugins/hoster/FastshareCz.py index 985faaa93..2919ebce2 100644 --- a/module/plugins/hoster/FastshareCz.py +++ b/module/plugins/hoster/FastshareCz.py @@ -49,7 +49,7 @@ class FastshareCz(SimpleHoster): def handle_free(self, pyfile): m = re.search(self.FREE_URL_PATTERN, self.html) - if m: + if m is not None: action, captcha_src = m.groups() else: self.error(_("FREE_URL_PATTERN not found")) @@ -70,7 +70,7 @@ class FastshareCz(SimpleHoster): self.retry(6, 10 * 60, _("Paralell download")) elif check == "wrong captcha": - self.retry(attemps=5, msg=_("Wrong captcha")) + self.retry_captcha() elif check == "credit": self.restart(nopremium=True) diff --git a/module/plugins/hoster/FileSharkPl.py b/module/plugins/hoster/FileSharkPl.py index 080e35438..23aa7ea61 100644 --- a/module/plugins/hoster/FileSharkPl.py +++ b/module/plugins/hoster/FileSharkPl.py @@ -50,12 +50,12 @@ class FileSharkPl(SimpleHoster): def check_errors(self): #: Check if file is now available for download (-> file name can be found in html body) m = re.search(self.WAIT_PATTERN, self.html) - if m: + if m is not None: errmsg = self.info['error'] = _("Another download already run") self.retry(15, int(m.group(1)), errmsg) m = re.search(self.ERROR_PATTERN, self.html) - if m: + if m is not None: alert = m.group(1) if re.match(self.IP_ERROR_PATTERN, alert): @@ -83,7 +83,7 @@ class FileSharkPl(SimpleHoster): self.html = self.load(link) m = re.search(self.WAIT_PATTERN, self.html) - if m: + if m is not None: seconds = int(m.group(1)) self.log_debug("Wait %s seconds" % seconds) self.wait(seconds) diff --git a/module/plugins/hoster/FileboomMe.py b/module/plugins/hoster/FileboomMe.py index 4328565f4..1a2c89b0b 100644 --- a/module/plugins/hoster/FileboomMe.py +++ b/module/plugins/hoster/FileboomMe.py @@ -39,64 +39,50 @@ class FileboomMe(SimpleHoster): post_url = urlparse.urljoin(pyfile.url, "file/" + self.info['pattern']['ID']) m = re.search(r'data-slow-id="(\w+)"', self.html) - if m: + if m is not None: self.html = self.load(post_url, post={'slow_id': m.group(1)}) m = re.search(self.LINK_PATTERN, self.html) - if m: + if m is not None: self.link = urlparse.urljoin(pyfile.url, m.group(0)) else: - for _i in xrange(5): - m = re.search(r'<input type="hidden" name="uniqueId" value="(\w+)">', self.html) - if m: - uniqueId = m.group(1) + m = re.search(r'<input type="hidden" name="uniqueId" value="(\w+)">', self.html) + if m is None: + m = re.search(r'>\s*Please wait ([\d:]+)', self.html) + if m is not None: + wait_time = 0 + for v in re.findall(r'(\d+)', m.group(1), re.I): + wait_time = 60 * wait_time + int(v) + self.wait(wait_time) + self.retry() - m = re.search(self.CAPTCHA_PATTERN, self.html) - if m: - captcha = self.captcha.decrypt(urlparse.urljoin(pyfile.url, m.group(1))) - - self.html = self.load(post_url, - post={'CaptchaForm[code]' : captcha, - 'free' : 1, - 'freeDownloadRequest': 1, - 'uniqueId' : uniqueId}) - - if 'The verification code is incorrect' in self.html: - self.captcha.invalid() - - else: - self.check_errors() - - self.html = self.load(post_url, - post={'free' : 1, - 'uniqueId': uniqueId}) - - m = re.search(self.LINK_PATTERN, self.html) - if m: - self.link = urlparse.urljoin(pyfile.url, m.group(0)) + else: + uniqueId = m.group(1) - else: - self.captcha.invalid() + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m is not None: + captcha = self.captcha.decrypt(urlparse.urljoin(pyfile.url, m.group(1))) + self.html = self.load(post_url, + post={'CaptchaForm[code]' : captcha, + 'free' : 1, + 'freeDownloadRequest': 1, + 'uniqueId' : uniqueId}) - break + if 'The verification code is incorrect' in self.html: + self.retry_captcha() else: - self.fail(_("Captcha not found")) - - else: - m = re.search(r'>\s*Please wait ([\d:]+)', self.html) - if m: - wait_time = 0 - for v in re.findall(r'(\d+)', m.group(1), re.I): - wait_time = 60 * wait_time + int(v) - self.wait(wait_time) - self.retry() - break + self.check_errors() - else: - self.fail(_("Invalid captcha")) + self.html = self.load(post_url, + post={'free' : 1, + 'uniqueId': uniqueId}) + + m = re.search(self.LINK_PATTERN, self.html) + if m is not None: + self.link = urlparse.urljoin(pyfile.url, m.group(0)) getInfo = create_getInfo(FileboomMe) diff --git a/module/plugins/hoster/FilecloudIo.py b/module/plugins/hoster/FilecloudIo.py index aa864271a..da81d3f37 100644 --- a/module/plugins/hoster/FilecloudIo.py +++ b/module/plugins/hoster/FilecloudIo.py @@ -78,22 +78,18 @@ class FilecloudIo(SimpleHoster): self.log_debug(res) if res['captcha']: data['ctype'] = "recaptcha" + data['recaptcha_response'], data['recaptcha_challenge'] = recaptcha.challenge(captcha_key) - for _i in xrange(5): - data['recaptcha_response'], data['recaptcha_challenge'] = recaptcha.challenge(captcha_key) + json_url = "http://filecloud.io/download-request.json" + res = self.load(json_url, post=data) + self.log_debug(res) + res = json_loads(res) - json_url = "http://filecloud.io/download-request.json" - res = self.load(json_url, post=data) - self.log_debug(res) - res = json_loads(res) - - if "retry" in res and res['retry']: - self.captcha.invalid() - else: - self.captcha.correct() - break + if "retry" in res and res['retry']: + self.retry_captcha() else: - self.fail(_("Incorrect captcha")) + self.captcha.correct() + if res['dl']: self.html = self.load('http://filecloud.io/download.html') diff --git a/module/plugins/hoster/FiledropperCom.py b/module/plugins/hoster/FiledropperCom.py index 3f5e2b761..8cef6c709 100644 --- a/module/plugins/hoster/FiledropperCom.py +++ b/module/plugins/hoster/FiledropperCom.py @@ -32,16 +32,14 @@ class FiledropperCom(SimpleHoster): def handle_free(self, pyfile): m = re.search(r'img id="img" src="(.+?)"', self.html) if m is None: - self.fail("Captcha not found") + self.fail(_("Captcha not found")) captcha_code = self.captcha.decrypt("http://www.filedropper.com/%s" % m.group(1)) m = re.search(r'method="post" action="(.+?)"', self.html) - if m is None: - self.fail("Download link not found") - - self.download(urlparse.urljoin("http://www.filedropper.com/", m.group(1)), - post={'code': captcha_code}) + if m is not None: + self.download(urlparse.urljoin("http://www.filedropper.com/", m.group(1)), + post={'code': captcha_code}) getInfo = create_getInfo(FiledropperCom) diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index e8890086b..637f3b2e0 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -50,12 +50,12 @@ class FilefactoryCom(SimpleHoster): m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: - self.error(_("Free download link not found")) + return self.link = m.group(1) m = re.search(self.WAIT_PATTERN, self.html) - if m: + if m is not None: self.wait(m.group(1)) @@ -65,21 +65,9 @@ class FilefactoryCom(SimpleHoster): if check == "multiple": self.log_debug("Parallel downloads detected; waiting 15 minutes") - self.retry(delay=15 * 60, msg=_("Parallel downloads")) + self.retry(wait=15 * 60, msg=_("Parallel downloads")) elif check == "error": self.error(_("Unknown error")) return super(FilefactoryCom, self).check_download() - - - def handle_premium(self, pyfile): - self.link = self.direct_link(self.load(pyfile.url, just_header=True)) - - if not self.link: - html = self.load(pyfile.url) - m = re.search(self.LINK_PREMIUM_PATTERN, html) - if m: - self.link = m.group(1) - else: - self.error(_("Premium download link not found")) diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index f2e3fb76d..3d42bebed 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -64,27 +64,20 @@ class FilepostCom(SimpleHoster): self.link = self.get_json_response(get_dict, post_dict, 'link') if not self.link: - self.fail(_("Incorrect password")) + self.fail(_("Wrong password")) else: self.fail(_("No password found")) else: - #: Solve recaptcha - recaptcha = ReCaptcha(self) - - for i in xrange(5): - get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml' - if i: - post_dict['recaptcha_response_field'], post_dict['recaptcha_challenge_field'] = recaptcha.challenge( - captcha_key) - self.log_debug(u"RECAPTCHA: %s : %s : %s" % ( - captcha_key, post_dict['recaptcha_challenge_field'], post_dict['recaptcha_response_field'])) + get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml' + self.link = self.get_json_response(get_dict, post_dict, 'link') + if not self.link: + #: Solve recaptcha + recaptcha = ReCaptcha(self) + post_dict['recaptcha_response_field'], post_dict['recaptcha_challenge_field'] = recaptcha.challenge(captcha_key) self.link = self.get_json_response(get_dict, post_dict, 'link') - else: - self.fail(_("Invalid captcha")) - def get_json_response(self, get_dict, post_dict, field): res = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)) @@ -101,8 +94,8 @@ class FilepostCom(SimpleHoster): if 'error' in res['js']: if res['js']['error'] == "download_delay": - self.retry(delay=res['js']['params']['next_download']) - #: ~? self.retry(delay=js_answer['params']['next_download']) + self.retry(wait=res['js']['params']['next_download']) + #: ~? self.retry(wait=js_answer['params']['next_download']) elif 'Wrong file password' in res['js']['error'] \ or 'You entered a wrong CAPTCHA code' in res['js']['error'] \ diff --git a/module/plugins/hoster/FilepupNet.py b/module/plugins/hoster/FilepupNet.py index 8bb23adb1..7793afe53 100644 --- a/module/plugins/hoster/FilepupNet.py +++ b/module/plugins/hoster/FilepupNet.py @@ -39,11 +39,9 @@ class FilepupNet(SimpleHoster): def handle_free(self, pyfile): m = re.search(self.LINK_FREE_PATTERN, self.html) - if m is None: - self.error(_("Download link not found")) - - dl_link = m.group(1) - self.download(dl_link, post={'task': "download"}) + if m is not None: + dl_link = m.group(1) + self.download(dl_link, post={'task': "download"}) getInfo = create_getInfo(FilepupNet) diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index af755e0a6..37c88dec7 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -57,10 +57,10 @@ class FilerNet(SimpleHoster): self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 1) if 'location' in self.req.http.header.lower(): - self.link = re.search(r'location: (\S+)', self.req.http.header, re.I).group(1) self.captcha.correct() + self.link = re.search(r'location: (\S+)', self.req.http.header, re.I).group(1) else: - self.captcha.invalid() + self.retry_captcha() getInfo = create_getInfo(FilerNet) diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index 36ccd473f..903e10349 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -95,7 +95,7 @@ class FileserveCom(Hoster): elif action['fail'] == "parallelDownload": self.log_warning(_("Parallel download error, now waiting 60s")) - self.retry(delay=60, msg=_("parallelDownload")) + self.retry(wait=60, msg=_("parallelDownload")) else: self.fail(_("Download check returned: %s") % action['fail']) @@ -161,19 +161,15 @@ class FileserveCom(Hoster): captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1) recaptcha = ReCaptcha(self) - for _i in xrange(5): - response, challenge = recaptcha.challenge(captcha_key) - res = json_loads(self.load(self.URLS[2], - post={'recaptcha_challenge_field' : challenge, - 'recaptcha_response_field' : response, - 'recaptcha_shortencode_field': self.file_id})) - if not res['success']: - self.captcha.invalid() - else: - self.captcha.correct() - break + response, challenge = recaptcha.challenge(captcha_key) + res = json_loads(self.load(self.URLS[2], + post={'recaptcha_challenge_field' : challenge, + 'recaptcha_response_field' : response, + 'recaptcha_shortencode_field': self.file_id})) + if res['success']: + self.captcha.correct() else: - self.fail(_("Invalid captcha")) + self.retry_captcha() def do_long_wait(self, m): diff --git a/module/plugins/hoster/FourSharedCom.py b/module/plugins/hoster/FourSharedCom.py index 212eadb3b..d767f4ca1 100644 --- a/module/plugins/hoster/FourSharedCom.py +++ b/module/plugins/hoster/FourSharedCom.py @@ -38,7 +38,7 @@ class FourSharedCom(SimpleHoster): def handle_free(self, pyfile): m = re.search(self.LINK_BTN_PATTERN, self.html) - if m: + if m is not None: link = m.group(1) else: link = re.sub(r'/(download|get|file|document|photo|video|audio)/', r'/get/', pyfile.url) @@ -47,7 +47,7 @@ class FourSharedCom(SimpleHoster): m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: - self.error(_("Download link")) + return self.link = m.group(1) diff --git a/module/plugins/hoster/FreakshareCom.py b/module/plugins/hoster/FreakshareCom.py index 72a1c0401..450f11095 100644 --- a/module/plugins/hoster/FreakshareCom.py +++ b/module/plugins/hoster/FreakshareCom.py @@ -61,8 +61,7 @@ class FreakshareCom(Hoster): self.fail(_("File not downloadable")) elif check == "wrong_captcha": - self.captcha.invalid() - self.retry() + self.retry_captcha() elif check == "downloadserver": self.retry(5, 15 * 60, _("No Download server")) @@ -111,7 +110,7 @@ class FreakshareCom(Hoster): if not self.wantReconnect: m = re.search(r"<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">([^ ]+)", self.html) - if m: + if m is not None: file_name = m.group(1) else: file_name = self.pyfile.url @@ -128,7 +127,7 @@ class FreakshareCom(Hoster): if not self.wantReconnect: m = re.search(r"<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">[^ ]+ - ([^ ]+) (\w\w)yte", self.html) - if m: + if m is not None: units = float(m.group(1).replace(",", "")) pow = {'KB': 1, 'MB': 2, 'GB': 3}[m.group(2)] size = int(units * 1024 ** pow) diff --git a/module/plugins/hoster/FshareVn.py b/module/plugins/hoster/FshareVn.py index a5aac222c..b387151f7 100644 --- a/module/plugins/hoster/FshareVn.py +++ b/module/plugins/hoster/FshareVn.py @@ -68,7 +68,7 @@ class FshareVn(SimpleHoster): self.html = self.load(url, post=inputs) if 'name="link_file_pwd_dl"' in self.html: - self.fail(_("Incorrect password")) + self.fail(_("Wrong password")) else: self.fail(_("No password found")) @@ -93,7 +93,7 @@ class FshareVn(SimpleHoster): self.offline() m = re.search(self.WAIT_PATTERN, self.html) - if m: + if m is not None: self.log_info(_("Wait until %s ICT") % m.group(1)) wait_until = time.mktime.time(time.strptime.time(m.group(1), "%d/%m/%Y %H:%M")) self.wait(wait_until - time.mktime.time(time.gmtime.time()) - 7 * 60 * 60, True) diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 2fa5c1aa8..2ff1755f4 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -71,7 +71,7 @@ class Ftp(Hoster): self.log_debug(self.req.http.header) m = re.search(r"Content-Length:\s*(\d+)", res) - if m: + if m is not None: pyfile.size = int(m.group(1)) self.download(pyfile.url) diff --git a/module/plugins/hoster/GigapetaCom.py b/module/plugins/hoster/GigapetaCom.py index 381c39a21..85e5e4843 100644 --- a/module/plugins/hoster/GigapetaCom.py +++ b/module/plugins/hoster/GigapetaCom.py @@ -36,23 +36,22 @@ class GigapetaCom(SimpleHoster): self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 0) - for _i in xrange(5): - self.check_errors() - - captcha = self.captcha.decrypt(captcha_url) - self.html = self.load(pyfile.url, post={ - 'captcha_key': captcha_key, - 'captcha': captcha, - 'download': "Download"}) - - m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I) - if m: - self.link = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 - break - elif "Entered figures don`t coincide with the picture" in self.html: - self.captcha.invalid() - else: - self.fail(_("No valid captcha code entered")) + self.check_errors() + + captcha = self.captcha.decrypt(captcha_url) + self.html = self.load(pyfile.url, post={ + 'captcha_key': captcha_key, + 'captcha': captcha, + 'download': "Download"}) + + m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I) + if m is not None: + self.captcha.correct() + self.link = m.group(1) + + elif "Entered figures don`t coincide with the picture" in self.html: + self.retry_captcha() + self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 1) diff --git a/module/plugins/hoster/GoogledriveCom.py b/module/plugins/hoster/GoogledriveCom.py index 381bd24dc..c6b84b776 100644 --- a/module/plugins/hoster/GoogledriveCom.py +++ b/module/plugins/hoster/GoogledriveCom.py @@ -41,17 +41,16 @@ class GoogledriveCom(SimpleHoster): m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: - self.error(_("Free download link not found")) + return + link = self.fixurl(link, "https://docs.google.com/") + direct_link = self.direct_link(link, False) + + if not direct_link: + self.html = self.load(link) else: - link = self.fixurl(link, "https://docs.google.com/") - direct_link = self.direct_link(link, False) - - if not direct_link: - self.html = self.load(link) - else: - self.link = direct_link - break + self.link = direct_link + break getInfo = create_getInfo(GoogledriveCom) diff --git a/module/plugins/hoster/HighWayMe.py b/module/plugins/hoster/HighWayMe.py index 5d990795f..53a8960c1 100644 --- a/module/plugins/hoster/HighWayMe.py +++ b/module/plugins/hoster/HighWayMe.py @@ -39,7 +39,7 @@ class HighWayMe(MultiHoster): elif "trafficlimit" in self.html: self.log_warning(_("Reached daily limit")) - self.retry(delay=seconds_to_midnight(), msg="Daily limit for this host reached") + self.retry(wait=seconds_to_midnight(), msg="Daily limit for this host reached") elif "<code>8</code>" in self.html: self.log_warning(_("Hoster temporarily unavailable, waiting 1 minute and retry")) diff --git a/module/plugins/hoster/HostujeNet.py b/module/plugins/hoster/HostujeNet.py index 4dbf550b3..3c0a53535 100644 --- a/module/plugins/hoster/HostujeNet.py +++ b/module/plugins/hoster/HostujeNet.py @@ -30,19 +30,19 @@ class HostujeNet(SimpleHoster): def handle_free(self, pyfile): m = re.search(r'<script src="([\w^_]+.php)"></script>', self.html) - if m: + if m is not None: jscript = self.load("http://hostuje.net/" + m.group(1)) m = re.search(r"\('(\w+\.php\?i=\w+)'\);", jscript) - if m: + if m is not None: self.load("http://hostuje.net/" + m.group(1)) else: - self.error(_("unexpected javascript format")) + self.error(_("Unexpected javascript format")) else: - self.error(_("script not found")) + self.error(_("Script not found")) action, inputs = self.parse_html_form(pyfile.url.replace(".", "\.").replace( "?", "\?")) if not action: - self.error(_("form not found")) + self.error(_("Form not found")) self.download(action, post=inputs) diff --git a/module/plugins/hoster/IfolderRu.py b/module/plugins/hoster/IfolderRu.py index 85d03489d..08e22a9df 100644 --- a/module/plugins/hoster/IfolderRu.py +++ b/module/plugins/hoster/IfolderRu.py @@ -45,21 +45,16 @@ class IfolderRu(SimpleHoster): self.get_fileInfo() session_id = re.search(self.SESSION_ID_PATTERN, self.html).groups() - captcha_url = "http://ints.rusfolder.com/random/images/?session=%s" % session_id - for _i in xrange(5): - action, inputs = self.parse_html_form('id="download-step-one-form"') - inputs['confirmed_number'] = self.captcha.decrypt(captcha_url, cookies=True) - inputs['action'] = '1' - self.log_debug(inputs) - - self.html = self.load(url, post=inputs) - if self.WRONG_CAPTCHA_PATTERN in self.html: - self.captcha.invalid() - else: - break - else: - self.fail(_("Invalid captcha")) + + action, inputs = self.parse_html_form('id="download-step-one-form"') + inputs['confirmed_number'] = self.captcha.decrypt(captcha_url, cookies=True) + inputs['action'] = '1' + self.log_debug(inputs) + + self.html = self.load(url, post=inputs) + if self.WRONG_CAPTCHA_PATTERN in self.html: + self.retry_captcha() self.link = re.search(self.LINK_FREE_PATTERN, self.html).group(1) diff --git a/module/plugins/hoster/Keep2ShareCc.py b/module/plugins/hoster/Keep2ShareCc.py index 1b9f69a02..427dbbec7 100644 --- a/module/plugins/hoster/Keep2ShareCc.py +++ b/module/plugins/hoster/Keep2ShareCc.py @@ -42,18 +42,18 @@ class Keep2ShareCc(SimpleHoster): def check_errors(self): m = re.search(self.TEMP_ERROR_PATTERN, self.html) - if m: + if m is not None: self.info['error'] = m.group(1) self.wantReconnect = True - self.retry(delay=30 * 60, msg=m.group(0)) + self.retry(wait=30 * 60, msg=m.group(0)) m = re.search(self.ERROR_PATTERN, self.html) - if m: + if m is not None: errmsg = self.info['error'] = m.group(1) self.error(errmsg) m = re.search(self.WAIT_PATTERN, self.html) - if m: + if m is not None: self.log_debug("Hoster told us to wait for %s" % m.group(1)) #: String to time convert courtesy of https://stackoverflow.com/questions/10663720 @@ -61,7 +61,7 @@ class Keep2ShareCc(SimpleHoster): wait_time = sum(a * b for a, b in zip(ftr, map(int, m.group(1).split(':')))) self.wantReconnect = True - self.retry(delay=wait_time, msg="Please wait to download this file") + self.retry(wait=wait_time, msg="Please wait to download this file") self.info.pop('error', None) @@ -95,11 +95,11 @@ class Keep2ShareCc(SimpleHoster): 'yt0' : ''} m = re.search(r'id="(captcha\-form)"', self.html) - self.log_debug("captcha-form found %s" % m) + self.log_debug("Captcha form found", m) m = re.search(self.CAPTCHA_PATTERN, self.html) self.log_debug("CAPTCHA_PATTERN found %s" % m) - if m: + if m is not None: captcha_url = urlparse.urljoin("http://keep2s.cc/", m.group(1)) post_data['CaptchaForm[code]'] = self.captcha.decrypt(captcha_url) else: @@ -110,10 +110,10 @@ class Keep2ShareCc(SimpleHoster): self.html = self.load(self.pyfile.url, post=post_data) - if 'verification code is incorrect' not in self.html: - self.captcha.correct() + if 'verification code is incorrect' in self.html: + self.retry_captcha() else: - self.captcha.invalid() + self.captcha.correct() getInfo = create_getInfo(Keep2ShareCc) diff --git a/module/plugins/hoster/KingfilesNet.py b/module/plugins/hoster/KingfilesNet.py index 98f74ad0d..3f7b0bfb9 100644 --- a/module/plugins/hoster/KingfilesNet.py +++ b/module/plugins/hoster/KingfilesNet.py @@ -56,7 +56,7 @@ class KingfilesNet(SimpleHoster): self.error(_("Random key not found")) rand = m.group(1) - self.log_debug("rand = ", rand) + self.log_debug("rand = " + rand) post_data = {'op' : "download2", 'id' : self.info['pattern']['ID'], diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 22d5c654a..b8a563007 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -60,7 +60,7 @@ class LetitbitNet(SimpleHoster): def handle_free(self, pyfile): action, inputs = self.parse_html_form('id="ifree_form"') if not action: - self.error(_("ifree_form")) + self.error(_("Form not found")) pyfile.size = float(inputs['sssize']) self.log_debug(action, inputs) @@ -99,17 +99,13 @@ class LetitbitNet(SimpleHoster): self.log_debug(res) - if not res: - self.captcha.invalid() + if not res or res == "error_wrong_captcha": + self.retry_captcha() - if res == "error_free_download_blocked": + elif res == "error_free_download_blocked": self.log_warning(_("Daily limit reached")) self.wait(seconds_to_midnight(), True) - if res == "error_wrong_captcha": - self.captcha.invalid() - self.retry() - elif res.startswith('['): urls = json_loads(res) diff --git a/module/plugins/hoster/LoadTo.py b/module/plugins/hoster/LoadTo.py index 7a42e0360..722f0e518 100644 --- a/module/plugins/hoster/LoadTo.py +++ b/module/plugins/hoster/LoadTo.py @@ -50,7 +50,7 @@ class LoadTo(SimpleHoster): #: Set Timer - may be obsolete m = re.search(self.WAIT_PATTERN, self.html) - if m: + if m is not None: self.wait(m.group(1)) #: Load.to is using solvemedia captchas since ~july 2014: diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index 71cccb71a..f9c7a89ef 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -29,10 +29,10 @@ class LuckyShareNet(SimpleHoster): if 'AJAX Error' in rep: html = self.load(self.pyfile.url) m = re.search(r"waitingtime = (\d+);", html) - if m: + if m is not None: seconds = int(m.group(1)) self.log_debug("You have to wait %d seconds between free downloads" % seconds) - self.retry(delay=seconds) + self.retry(wait=seconds) else: self.error(_("Unable to detect wait time between free downloads")) elif 'Hash expired' in rep: @@ -52,24 +52,20 @@ class LuckyShareNet(SimpleHoster): recaptcha = ReCaptcha(self) - for _i in xrange(5): - response, challenge = recaptcha.challenge() - rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" % - (challenge, response, json['hash'])) - self.log_debug("JSON: " + rep) - if 'link' in rep: - json.update(self.parse_json(rep)) - self.captcha.correct() - break - elif 'Verification failed' in rep: - self.captcha.invalid() - else: - self.error(_("Unable to get downlaod link")) + response, challenge = recaptcha.challenge() + rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" % + (challenge, response, json['hash'])) + + self.log_debug("JSON: " + rep) - if not json['link']: - self.fail(_("No Download url retrieved/all captcha attempts failed")) + if 'Verification failed' in rep: + self.retry_captcha() - self.link = json['link'] + elif 'link' in rep: + self.captcha.correct() + json.update(self.parse_json(rep)) + if json['link']: + self.link = json['link'] getInfo = create_getInfo(LuckyShareNet) diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index 21e643171..1abe87cd2 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -69,7 +69,7 @@ class MediafireCom(SimpleHoster): self.html = self.load(self.link, post={'downloadp': password}) if self.PASSWORD_PATTERN in self.html: - self.fail(_("Incorrect password")) + self.fail(_("Wrong password")) return super(MediafireCom, self).handle_free(pyfile) diff --git a/module/plugins/hoster/MegaDebridEu.py b/module/plugins/hoster/MegaDebridEu.py index 4afba0a3a..0dfc16c34 100644 --- a/module/plugins/hoster/MegaDebridEu.py +++ b/module/plugins/hoster/MegaDebridEu.py @@ -48,7 +48,7 @@ class MegaDebridEu(MultiHoster): Return The debrided link if succeed or original link if fail """ if not self.api_load(): - self.error("Unable to connect to remote API") + self.error(_("Unable to connect to remote API")) jsonResponse = self.load(self.API_URL, get={'action': 'getLink', 'token': self.token}, diff --git a/module/plugins/hoster/MegaRapidCz.py b/module/plugins/hoster/MegaRapidCz.py index c3cf8a2b6..69c1c411b 100644 --- a/module/plugins/hoster/MegaRapidCz.py +++ b/module/plugins/hoster/MegaRapidCz.py @@ -54,15 +54,12 @@ class MegaRapidCz(SimpleHoster): def handle_premium(self, pyfile): m = re.search(self.LINK_PREMIUM_PATTERN, self.html) - if m: + if m is not None: self.link = m.group(1) - else: - if re.search(self.ERR_LOGIN_PATTERN, self.html): - self.relogin() - self.retry(delay=60, msg=_("User login failed")) - elif re.search(self.ERR_CREDIT_PATTERN, self.html): - self.fail(_("Not enough credit left")) + elif re.search(self.ERR_LOGIN_PATTERN, self.html): + self.relogin() + self.retry(wait=60, msg=_("User login failed")) - else: - self.fail(_("Download link not found")) + elif re.search(self.ERR_CREDIT_PATTERN, self.html): + self.fail(_("Not enough credit left")) diff --git a/module/plugins/hoster/MegaRapidoNet.py b/module/plugins/hoster/MegaRapidoNet.py index b00daf713..573586639 100644 --- a/module/plugins/hoster/MegaRapidoNet.py +++ b/module/plugins/hoster/MegaRapidoNet.py @@ -42,15 +42,15 @@ class MegaRapidoNet(MultiHoster): def handle_premium(self, pyfile): self.html = self.load("http://megarapido.net/gerar.php", - post={'rand' :random_with_N_digits(16), - 'urllist' : pyfile.url, - 'links' : pyfile.url, - 'exibir' : "normal", - 'usar' : "premium", - 'user' : self.account.get_data('sid'), - 'autoreset': ""}) + post={'rand' :random_with_N_digits(16), + 'urllist' : pyfile.url, + 'links' : pyfile.url, + 'exibir' : "normal", + 'usar' : "premium", + 'user' : self.account.get_data('sid'), + 'autoreset': ""}) if "desloga e loga novamente para gerar seus links" in self.html.lower(): - self.error("You have logged in at another place") + self.error(_("You have logged in at another place")) return super(MegaRapidoNet, self).handle_premium(pyfile) diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index deee700ba..04fae27b4 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -46,43 +46,40 @@ class MegasharesCom(SimpleHoster): def handle_free(self, pyfile): if self.NO_SLOTS_PATTERN in self.html: - self.retry(delay=5 * 60) + self.retry(wait=5 * 60) m = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html) - if m: + if m is not None: passport_num = m.group(1) request_uri = re.search(self.REQUEST_URI_PATTERN, self.html).group(1) - for _i in xrange(5): - random_num = re.search(self.REACTIVATE_NUM_PATTERN, self.html).group(1) + random_num = re.search(self.REACTIVATE_NUM_PATTERN, self.html).group(1) - verifyinput = self.captcha.decrypt("http://d01.megashares.com/index.php", - get={'secgfx': "gfx", 'random_num': random_num}) + verifyinput = self.captcha.decrypt("http://d01.megashares.com/index.php", + get={'secgfx': "gfx", 'random_num': random_num}) - self.log_info(_("Reactivating passport %s: %s %s") % (passport_num, random_num, verifyinput)) + self.log_info(_("Reactivating passport %s: %s %s") % (passport_num, random_num, verifyinput)) - res = self.load("http://d01.megashares.com%s" % request_uri, - get={'rs' : "check_passport_renewal", - 'rsargs[]': verifyinput, - 'rsargs[]': random_num, - 'rsargs[]': passport_num, - 'rsargs[]': "replace_sec_pprenewal", - 'rsrnd[]' : str(int(time.time() * 1000))}) + res = self.load("http://d01.megashares.com%s" % request_uri, + get={'rs' : "check_passport_renewal", + 'rsargs[]': verifyinput, + 'rsargs[]': random_num, + 'rsargs[]': passport_num, + 'rsargs[]': "replace_sec_pprenewal", + 'rsrnd[]' : str(int(time.time() * 1000))}) - if 'Thank you for reactivating your passport.' in res: - self.captcha.correct() - self.retry() - else: - self.captcha.invalid() + if 'Thank you for reactivating your passport' in res: + self.captcha.correct() + self.restart() else: - self.fail(_("Failed to reactivate passport")) + self.retry_captcha(msg=_("Failed to reactivate passport")) m = re.search(self.PASSPORT_RENEW_PATTERN, self.html) - if m: + if m is not None: time = [int(x) for x in m.groups()] renew = time[0] + (time[1] * 60) + (time[2] * 60) self.log_debug("Waiting %d seconds for a new passport" % renew) - self.retry(delay=renew, msg=_("Passport renewal")) + self.retry(wait=renew, msg=_("Passport renewal")) #: Check traffic left on passport m = re.search(self.PASSPORT_LEFT_PATTERN, self.html, re.M | re.S) @@ -94,13 +91,12 @@ class MegasharesCom(SimpleHoster): self.log_info(_("Data left: %s %s (%d MB needed)") % (m.group(2), m.group(3), self.pyfile.size / 1048576)) if not data_left: - self.retry(delay=600, msg=_("Passport renewal")) + self.retry(wait=600, msg=_("Passport renewal")) self.handle_download(False) def handle_download(self, premium=False): - #: Find download link m = re.search(self.LINK_PATTERN % (1 if premium else 2), self.html) msg = _('%s download URL' % ('Premium' if premium else 'Free')) if m is None: diff --git a/module/plugins/hoster/MystoreTo.py b/module/plugins/hoster/MystoreTo.py index e4432f491..b23ca10bd 100644 --- a/module/plugins/hoster/MystoreTo.py +++ b/module/plugins/hoster/MystoreTo.py @@ -19,7 +19,7 @@ class MystoreTo(SimpleHoster): __description__ = """Mystore.to hoster plugin""" __license__ = "GPLv3" - __authors__ = [("zapp-brannigan", "")] + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")] NAME_PATTERN = r'<h1>(?P<N>.+?)<' diff --git a/module/plugins/hoster/NarodRu.py b/module/plugins/hoster/NarodRu.py index a20c23954..bea04c9cd 100644 --- a/module/plugins/hoster/NarodRu.py +++ b/module/plugins/hoster/NarodRu.py @@ -34,33 +34,25 @@ class NarodRu(SimpleHoster): def handle_free(self, pyfile): - for _i in xrange(5): - self.html = self.load('http://narod.ru/disk/getcapchaxml/?rnd=%d' % int(random.random() * 777)) + self.html = self.load('http://narod.ru/disk/getcapchaxml/?rnd=%d' % int(random.random() * 777)) - m = re.search(self.CAPTCHA_PATTERN, self.html) - if m is None: - self.error(_("Captcha")) + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m is None: + self.error(_("Captcha")) - post_data = {'action': "sendcapcha"} - captcha_url, post_data['key'] = m.groups() - post_data['rep'] = self.captcha.decrypt(captcha_url) + post_data = {'action': "sendcapcha"} + captcha_url, post_data['key'] = m.groups() + post_data['rep'] = self.captcha.decrypt(captcha_url) - self.html = self.load(pyfile.url, post=post_data) + self.html = self.load(pyfile.url, post=post_data) - m = re.search(self.LINK_FREE_PATTERN, self.html) - if m: - self.link = urlparse.urljoin("http://narod.ru/", m.group(1)) - self.captcha.correct() - break + m = re.search(self.LINK_FREE_PATTERN, self.html) + if m is not None: + self.captcha.correct() + self.link = urlparse.urljoin("http://narod.ru/", m.group(1)) - elif u'<b class="error-msg"><strong>Ошиблись?</strong>' in self.html: - self.captcha.invalid() - - else: - self.error(_("Download link")) - - else: - self.fail(_("No valid captcha code entered")) + elif u'<b class="error-msg"><strong>Ошиблись?</strong>' in self.html: + self.retry_captcha() getInfo = create_getInfo(NarodRu) diff --git a/module/plugins/hoster/NoPremiumPl.py b/module/plugins/hoster/NoPremiumPl.py index 0826d5252..8657d4527 100644 --- a/module/plugins/hoster/NoPremiumPl.py +++ b/module/plugins/hoster/NoPremiumPl.py @@ -66,14 +66,14 @@ class NoPremiumPl(MultiHoster): data = self.run_file_query(pyfile.url, 'fileinfo') except Exception: - self.log_debug("runFileQuery error") + self.log_debug("Query error #1") self.temp_offline() try: parsed = json_loads(data) except Exception: - self.log_debug("loads error") + self.log_debug("Data not found") self.temp_offline() self.log_debug(parsed) @@ -100,5 +100,5 @@ class NoPremiumPl(MultiHoster): self.link = self.run_file_query(pyfile.url, 'filedownload') except Exception: - self.log_debug("runFileQuery error #2") + self.log_debug("Query error #2") self.temp_offline() diff --git a/module/plugins/hoster/NosuploadCom.py b/module/plugins/hoster/NosuploadCom.py index 7de26f3fb..45521eebf 100644 --- a/module/plugins/hoster/NosuploadCom.py +++ b/module/plugins/hoster/NosuploadCom.py @@ -25,18 +25,18 @@ class NosuploadCom(XFSHoster): def get_download_link(self): - #: stage1: press the "Free Download" button + #: Stage1: press the "Free Download" button data = self.get_post_parameters() self.html = self.load(self.pyfile.url, post=data) - #: stage2: wait some time and press the "Download File" button + #: Stage2: wait some time and press the "Download File" button data = self.get_post_parameters() wait_time = re.search(self.WAIT_PATTERN, self.html, re.M | re.S).group(1) self.log_debug("Hoster told us to wait %s seconds" % wait_time) self.wait(wait_time) self.html = self.load(self.pyfile.url, post=data) - #: stage3: get the download link + #: Stage3: get the download link return re.search(self.LINK_PATTERN, self.html, re.S).group(1) diff --git a/module/plugins/hoster/NowDownloadSx.py b/module/plugins/hoster/NowDownloadSx.py index 5aadd0b3f..73b0efeaa 100644 --- a/module/plugins/hoster/NowDownloadSx.py +++ b/module/plugins/hoster/NowDownloadSx.py @@ -44,7 +44,7 @@ class NowDownloadSx(SimpleHoster): self.error() m = re.search(self.WAIT_PATTERN, self.html) - if m: + if m is not None: wait = int(m.group(1)) else: wait = 60 @@ -56,10 +56,8 @@ class NowDownloadSx(SimpleHoster): self.html = self.load(baseurl + str(continuelink.group(1))) m = re.search(self.LINK_FREE_PATTERN, self.html) - if m is None: - self.error(_("Download link not found")) - - self.link = m.group(1) + if m is not None: + self.link = m.group(1) getInfo = create_getInfo(NowDownloadSx) diff --git a/module/plugins/hoster/NowVideoSx.py b/module/plugins/hoster/NowVideoSx.py index c1f369f2a..b919d74ab 100644 --- a/module/plugins/hoster/NowVideoSx.py +++ b/module/plugins/hoster/NowVideoSx.py @@ -37,10 +37,8 @@ class NowVideoSx(SimpleHoster): self.html = self.load("http://www.nowvideo.sx/mobile/video.php", get={'id': self.info['pattern']['ID']}) m = re.search(self.LINK_FREE_PATTERN, self.html) - if m is None: - self.error(_("Free download link not found")) - - self.link = m.group(1) + if m is not None: + self.link = m.group(1) getInfo = create_getInfo(NowVideoSx) diff --git a/module/plugins/hoster/OboomCom.py b/module/plugins/hoster/OboomCom.py index d294ae3c6..77cf6b68f 100644 --- a/module/plugins/hoster/OboomCom.py +++ b/module/plugins/hoster/OboomCom.py @@ -74,41 +74,36 @@ class OboomCom(Hoster): def solve_captcha(self): recaptcha = ReCaptcha(self) + response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY) - for _i in xrange(5): - response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY) - apiUrl = "http://www.oboom.com/1.0/download/ticket" - params = {'recaptcha_challenge_field': challenge, - 'recaptcha_response_field': response, - 'download_id': self.file_id, - 'token': self.session_token} - result = self.load_url(apiUrl, params) + apiUrl = "http://www.oboom.com/1.0/download/ticket" + params = {'recaptcha_challenge_field': challenge, + 'recaptcha_response_field': response, + 'download_id': self.file_id, + 'token': self.session_token} - if result[0] == 200: - self.download_token = result[1] - self.download_auth = result[2] - self.captcha.correct() - self.wait(30) - break - - elif result[0] == 400: - if result[1] == "incorrect-captcha-sol": - self.captcha.invalid() - elif result[1] == "captcha-timeout": - self.captcha.invalid() - elif result[1] == "forbidden": - self.retry(5, 15 * 60, _("Service unavailable")) - - elif result[0] == 403: + result = self.load_url(apiUrl, params) + + if result[0] == 200: + self.download_token = result[1] + self.download_auth = result[2] + self.captcha.correct() + self.wait(30) + + else: + if result[0] == 403: if result[1] == -1: #: Another download is running self.set_wait(15 * 60) else: self.set_wait(result[1], True) + self.wait() self.retry(5) - else: - self.captcha.invalid() - self.fail(_("Received invalid captcha 5 times")) + + elif result[0] == 400 and result[1] == "forbidden": + self.retry(5, 15 * 60, _("Service unavailable")) + + self.retry_captcha() def get_fileInfo(self, token, fileId): @@ -141,6 +136,6 @@ class OboomCom(Hoster): self.download_domain = result[1] self.download_ticket = result[2] elif result[0] == 421: - self.retry(delay=result[2] + 60, msg=_("Connection limit exceeded")) + self.retry(wait=result[2] + 60, msg=_("Connection limit exceeded")) else: self.fail(_("Could not retrieve download ticket. Error code: %s") % result[0]) diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py index 70229a6ef..f525e5b33 100644 --- a/module/plugins/hoster/OneFichierCom.py +++ b/module/plugins/hoster/OneFichierCom.py @@ -102,7 +102,7 @@ class OneFichierCom(SimpleHoster): url, inputs = self.parse_html_form('action="https://1fichier.com/\?%s' % id) if not url: - self.fail(_("Download link not found")) + return if "pass" in inputs: inputs['pass'] = self.get_password() diff --git a/module/plugins/hoster/PornhostCom.py b/module/plugins/hoster/PornhostCom.py index 8b0a80c7f..e9d199a2e 100644 --- a/module/plugins/hoster/PornhostCom.py +++ b/module/plugins/hoster/PornhostCom.py @@ -49,7 +49,7 @@ class PornhostCom(Hoster): url = re.search(r'"http://file\d+\.pornhost\.com/\d+/.*?"', self.html) #@TODO: fix this one since it doesn't match - return url.group(1).strip() + return url.group(1) def get_file_name(self): diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py index 5345566a1..ce6badedd 100644 --- a/module/plugins/hoster/PornhubCom.py +++ b/module/plugins/hoster/PornhubCom.py @@ -67,7 +67,7 @@ class PornhubCom(Hoster): self.download_html() m = re.search(r'<title.+?>([^<]+) - ', self.html) - if m: + if m is not None: name = m.group(1) else: matches = re.findall('<h1>(.*?)</h1>', self.html) diff --git a/module/plugins/hoster/PremiumizeMe.py b/module/plugins/hoster/PremiumizeMe.py index e682a5a4c..16c252dc1 100644 --- a/module/plugins/hoster/PremiumizeMe.py +++ b/module/plugins/hoster/PremiumizeMe.py @@ -54,7 +54,7 @@ class PremiumizeMe(MultiHoster): return elif status == 400: - self.fail(_("Invalid link")) + self.fail(_("Invalid url")) elif status == 404: self.offline() diff --git a/module/plugins/hoster/QuickshareCz.py b/module/plugins/hoster/QuickshareCz.py index 2baef4c6d..62240667c 100644 --- a/module/plugins/hoster/QuickshareCz.py +++ b/module/plugins/hoster/QuickshareCz.py @@ -69,12 +69,12 @@ class QuickshareCz(SimpleHoster): if m is None: self.fail(_("File not found")) - self.link = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 + self.link = m.group(1) self.log_debug("FREE URL2:" + self.link) #: Check errors m = re.search(r'/chyba/(\d+)', self.link) - if m: + if m is not None: if m.group(1) == "1": self.retry(60, 2 * 60, "This IP is already downloading") elif m.group(1) == "2": diff --git a/module/plugins/hoster/RPNetBiz.py b/module/plugins/hoster/RPNetBiz.py index 5207832ee..cbe3e2a52 100644 --- a/module/plugins/hoster/RPNetBiz.py +++ b/module/plugins/hoster/RPNetBiz.py @@ -28,7 +28,6 @@ class RPNetBiz(MultiHoster): def handle_premium(self, pyfile): user, info = self.account.select() - #: Get the download link res = self.load("https://premium.rpnet.biz/client_api.php", get={'username': user, 'password': info['login']['password'], diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py index 3f2003034..711f33e87 100644 --- a/module/plugins/hoster/RapidgatorNet.py +++ b/module/plugins/hoster/RapidgatorNet.py @@ -86,7 +86,7 @@ class RapidgatorNet(SimpleHoster): else: self.account.relogin() - self.retry(delay=60) + self.retry(wait=60) def handle_premium(self, pyfile): @@ -122,29 +122,25 @@ class RapidgatorNet(SimpleHoster): url = "http://rapidgator.net%s" % jsvars.get('captchaUrl', '/download/captcha') self.html = self.load(url) - for _i in xrange(5): - m = re.search(self.LINK_FREE_PATTERN, self.html) - if m: - self.link = m.group(1) - break - else: - captcha = self.handle_captcha() + m = re.search(self.LINK_FREE_PATTERN, self.html) + if m is not None: + self.link = m.group(1) + else: + captcha = self.handle_captcha() - if not captcha: - self.error(_("Captcha pattern not found")) + if not captcha: + self.error(_("Captcha pattern not found")) - response, challenge = captcha.challenge() + response, challenge = captcha.challenge() - self.html = self.load(url, post={'DownloadCaptchaForm[captcha]': "", - 'adcopy_challenge' : challenge, - 'adcopy_response' : response}) + self.html = self.load(url, post={'DownloadCaptchaForm[captcha]': "", + 'adcopy_challenge' : challenge, + 'adcopy_response' : response}) - if "The verification code is incorrect" in self.html: - self.captcha.invalid() - else: - self.captcha.correct() - else: - self.error(_("Download link")) + if "The verification code is incorrect" in self.html: + self.retry_captcha() + else: + self.captcha.correct() def handle_captcha(self): diff --git a/module/plugins/hoster/RapiduNet.py b/module/plugins/hoster/RapiduNet.py index 267f41f36..99c877226 100644 --- a/module/plugins/hoster/RapiduNet.py +++ b/module/plugins/hoster/RapiduNet.py @@ -20,7 +20,7 @@ class RapiduNet(SimpleHoster): __description__ = """Rapidu.net hoster plugin""" __license__ = "GPLv3" - __authors__ = [("prOq", "")] + __authors__ = [("prOq", None)] COOKIES = [("rapidu.net", "rapidu_lang", "en")] diff --git a/module/plugins/hoster/SendspaceCom.py b/module/plugins/hoster/SendspaceCom.py index 13dd20b7c..ece048ed9 100644 --- a/module/plugins/hoster/SendspaceCom.py +++ b/module/plugins/hoster/SendspaceCom.py @@ -30,32 +30,31 @@ class SendspaceCom(SimpleHoster): def handle_free(self, pyfile): - params = {} - for _i in xrange(3): - m = re.search(self.LINK_FREE_PATTERN, self.html) - if m: - if 'captcha_hash' in params: - self.captcha.correct() - self.link = m.group(1) - break + m = re.search(self.LINK_FREE_PATTERN, self.html) + if m is not None: + self.link = m.group(1) + else: m = re.search(self.CAPTCHA_PATTERN, self.html) - if m: - if 'captcha_hash' in params: - self.captcha.invalid() + if m is None: + params = {'download': "Regular Download"} + else: captcha_url1 = "http://www.sendspace.com/" + m.group(1) m = re.search(self.USER_CAPTCHA_PATTERN, self.html) captcha_url2 = "http://www.sendspace.com/" + m.group(1) params = {'captcha_hash': m.group(2), 'captcha_submit': 'Verify', 'captcha_answer': self.captcha.decrypt(captcha_url1) + " " + self.captcha.decrypt(captcha_url2)} - else: - params = {'download': "Regular Download"} self.log_debug(params) + self.html = self.load(pyfile.url, post=params) - else: - self.fail(_("Download link not found")) + + m = re.search(self.LINK_FREE_PATTERN, self.html) + if m is None: + self.retry_captcha() + else: + self.link = m.group(1) getInfo = create_getInfo(SendspaceCom) diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 56177f97a..a8f4a5c8b 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -67,25 +67,20 @@ class ShareonlineBiz(SimpleHoster): def handle_captcha(self): recaptcha = ReCaptcha(self) - - for _i in xrange(5): - response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY) - - m = re.search(r'var wait=(\d+);', self.html) - self.set_wait(int(m.group(1)) if m else 30) - - res = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time.time() * 1000)), - post={'dl_free' : "1", - 'recaptcha_challenge_field': challenge, - 'recaptcha_response_field' : response}) - if res != "0": - self.captcha.correct() - return res - else: - self.captcha.invalid() + response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY) + + m = re.search(r'var wait=(\d+);', self.html) + self.set_wait(int(m.group(1)) if m else 30) + + res = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time.time() * 1000)), + post={'dl_free' : "1", + 'recaptcha_challenge_field': challenge, + 'recaptcha_response_field' : response}) + if res != "0": + self.captcha.correct() + return res else: - self.captcha.invalid() - self.fail(_("No valid captcha solution received")) + self.retry_captcha() def handle_free(self, pyfile): @@ -100,7 +95,7 @@ class ShareonlineBiz(SimpleHoster): self.link = res.decode('base64') if not self.link.startswith("http://"): - self.error(_("Wrong download url")) + self.error(_("Invalid url")) self.wait() @@ -110,12 +105,10 @@ class ShareonlineBiz(SimpleHoster): 'fail' : re.compile(r"<title>Share-Online")}) if check == "cookie": - self.captcha.invalid() - self.retry(5, 60, _("Cookie failure")) + self.retry_captcha(5, 60, _("Cookie failure")) elif check == "fail": - self.captcha.invalid() - self.retry(5, 5 * 60, _("Download failed")) + self.retry_captcha(5, 5 * 60, _("Download failed")) return super(ShareonlineBiz, self).check_download() @@ -170,7 +163,7 @@ class ShareonlineBiz(SimpleHoster): self.fail(_("Premium account needed")) elif errmsg in ("expired", "server"): - self.retry(delay=600, msg=errmsg) + self.retry(wait=600, msg=errmsg) elif errmsg == "full": self.retry(10, 600, _("Server is full")) @@ -181,7 +174,7 @@ class ShareonlineBiz(SimpleHoster): else: self.wantReconnect = True - self.retry(delay=60, msg=errmsg) + self.retry(wait=60, msg=errmsg) getInfo = create_getInfo(ShareonlineBiz) diff --git a/module/plugins/hoster/ShareplaceCom.py b/module/plugins/hoster/ShareplaceCom.py index 11aef0c90..6b4cfed2b 100644 --- a/module/plugins/hoster/ShareplaceCom.py +++ b/module/plugins/hoster/ShareplaceCom.py @@ -40,7 +40,7 @@ class ShareplaceCom(Hoster): #: var zzipitime = 15 m = re.search(r'var zzipitime = (\d+);', self.html) - if m: + if m is not None: sec = int(m.group(1)) else: sec = 0 diff --git a/module/plugins/hoster/SimplyPremiumCom.py b/module/plugins/hoster/SimplyPremiumCom.py index 01b21079d..8e3890fb8 100644 --- a/module/plugins/hoster/SimplyPremiumCom.py +++ b/module/plugins/hoster/SimplyPremiumCom.py @@ -40,7 +40,7 @@ class SimplyPremiumCom(MultiHoster): elif "trafficlimit" in self.html: self.log_warning(_("Reached daily limit for this host")) - self.retry(delay=seconds_to_midnight(), msg="Daily limit for this host reached") + self.retry(wait=seconds_to_midnight(), msg="Daily limit for this host reached") elif "hostererror" in self.html: self.log_warning(_("Hoster temporarily unavailable, waiting 1 minute and retry")) diff --git a/module/plugins/hoster/SizedriveCom.py b/module/plugins/hoster/SizedriveCom.py index 8bfe46e86..d0db9985b 100644 --- a/module/plugins/hoster/SizedriveCom.py +++ b/module/plugins/hoster/SizedriveCom.py @@ -35,7 +35,7 @@ class SizedriveCom(SimpleHoster): post={'id': self.info['pattern']['ID']}) m = re.search(r'<span id="boton_download" ><a href="(.+?)"', self.html) - if m: + if m is not None: self.link = m.group(1) diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py index 67e590cec..e864bb2c0 100644 --- a/module/plugins/hoster/SmoozedCom.py +++ b/module/plugins/hoster/SmoozedCom.py @@ -16,7 +16,7 @@ class SmoozedCom(MultiHoster): __description__ = """Smoozed.com hoster plugin""" __license__ = "GPLv3" - __authors__ = [("", "")] + __authors__ = [(None, None)] FILE_ERRORS = [("Error", r'{"state":"error"}'), diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py index d323a214b..aad56788c 100644 --- a/module/plugins/hoster/TurbobitNet.py +++ b/module/plugins/hoster/TurbobitNet.py @@ -56,64 +56,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 +122,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)) diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index ba9ac390e..cc07770d4 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -52,7 +52,7 @@ class UlozTo(SimpleHoster): if not action or not inputs: self.error(_("Free download form not found")) - self.log_debug("inputs.keys = " + str(inputs.keys())) + self.log_debug("inputs.keys = %s" % inputs.keys()) #: Get and decrypt captcha if all(key in inputs for key in ("captcha_value", "captcha_id", "captcha_key")): #: Old version - last seen 9.12.2013 @@ -70,7 +70,7 @@ class UlozTo(SimpleHoster): xapca = self.load("http://www.ulozto.net/reloadXapca.php", get={'rnd': str(int(time.time()))}) xapca = xapca.replace('sound":"', 'sound":"http:').replace('image":"', 'image":"http:') - self.log_debug("xapca = " + str(xapca)) + self.log_debug("xapca = %s" % xapca) data = json_loads(xapca) captcha_value = self.captcha.decrypt(str(data['image'])) @@ -110,7 +110,7 @@ class UlozTo(SimpleHoster): post={'password': password, 'password_send': 'Send'}) if self.PASSWD_PATTERN in self.html: - self.fail(_("Incorrect password")) + self.fail(_("Wrong password")) else: self.fail(_("No password found")) @@ -130,8 +130,7 @@ class UlozTo(SimpleHoster): }) if check == "wrong_captcha": - self.captcha.invalid() - self.retry(msg=_("Wrong captcha code")) + self.retry_captcha() elif check == "offline": self.offline() diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index 12e88cf1c..5bbbb1f7c 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -35,7 +35,7 @@ class UloziskoSk(SimpleHoster): self.get_fileInfo() m = re.search(self.IMG_PATTERN, self.html) - if m: + if m is not None: self.link = "http://ulozisko.sk" + m.group(1) else: self.handle_free(pyfile) diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index b82c04ad1..50006dd27 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -40,7 +40,7 @@ class UnibytesCom(SimpleHoster): self.html = self.load(urlparse.urljoin(domain, action), post=post_data) m = re.search(r'location:\s*(\S+)', self.req.http.header, re.I) - if m: + if m is not None: self.link = m.group(1) break @@ -50,12 +50,12 @@ class UnibytesCom(SimpleHoster): if post_data['step'] == "last": m = re.search(self.LINK_FREE_PATTERN, self.html) - if m: - self.link = m.group(1) + if m is not None: self.captcha.correct() + self.link = m.group(1) break else: - self.captcha.invalid() + self.retry_captcha() last_step = post_data['step'] action, post_data = self.parse_html_form('id="stepForm"') diff --git a/module/plugins/hoster/UpleaCom.py b/module/plugins/hoster/UpleaCom.py index 15d47dec5..9c422ce01 100644 --- a/module/plugins/hoster/UpleaCom.py +++ b/module/plugins/hoster/UpleaCom.py @@ -49,7 +49,7 @@ class UpleaCom(XFSHoster): self.html = self.load(urlparse.urljoin("http://uplea.com/", m.group(1))) m = re.search(self.WAIT_PATTERN, self.html) - if m: + if m is not None: self.log_debug("Waiting %s seconds" % m.group(1)) self.wait(m.group(1), True) self.retry() diff --git a/module/plugins/hoster/UploadheroCom.py b/module/plugins/hoster/UploadheroCom.py index ded0d60dd..517ed293a 100644 --- a/module/plugins/hoster/UploadheroCom.py +++ b/module/plugins/hoster/UploadheroCom.py @@ -50,14 +50,14 @@ class UploadheroCom(SimpleHoster): get={'code': captcha}) m = re.search(self.LINK_FREE_PATTERN, self.html) - if m: + if m is not None: self.link = m.group(1) or m.group(2) self.wait(50) def check_errors(self): m = re.search(self.IP_BLOCKED_PATTERN, self.html) - if m: + if m is not None: self.html = self.load(urlparse.urljoin("http://uploadhero.co/", m.group(1))) m = re.search(self.IP_WAIT_PATTERN, self.html) diff --git a/module/plugins/hoster/UploadingCom.py b/module/plugins/hoster/UploadingCom.py index 36f0c766e..a7878f731 100644 --- a/module/plugins/hoster/UploadingCom.py +++ b/module/plugins/hoster/UploadingCom.py @@ -61,7 +61,7 @@ class UploadingCom(SimpleHoster): def handle_free(self, pyfile): m = re.search('<h2>((Daily )?Download Limit)</h2>', self.html) - if m: + if m is not None: pyfile.error = encode(m.group(1)) self.log_warning(pyfile.error) self.retry(6, (6 * 60 if m.group(2) else 15) * 60, pyfile.error) @@ -88,7 +88,7 @@ class UploadingCom(SimpleHoster): self.html = self.load(url) m = re.search(r'<form id="file_form" action="(.*?)"', self.html) - if m: + if m is not None: url = m.group(1) else: self.error(_("No URL")) diff --git a/module/plugins/hoster/UpstoreNet.py b/module/plugins/hoster/UpstoreNet.py index 12c667efb..caa12e8af 100644 --- a/module/plugins/hoster/UpstoreNet.py +++ b/module/plugins/hoster/UpstoreNet.py @@ -62,13 +62,11 @@ class UpstoreNet(SimpleHoster): #: STAGE 3: get direct link m = re.search(self.LINK_FREE_PATTERN, self.html, re.S) - if m: + if m is not None: break - if m is None: - self.error(_("Download link not found")) - - self.link = m.group(1) + if m is not None: + self.link = m.group(1) getInfo = create_getInfo(UpstoreNet) diff --git a/module/plugins/hoster/VeohCom.py b/module/plugins/hoster/VeohCom.py index 7d46ee335..ba18fd529 100644 --- a/module/plugins/hoster/VeohCom.py +++ b/module/plugins/hoster/VeohCom.py @@ -42,7 +42,7 @@ class VeohCom(SimpleHoster): for q in quality: pattern = r'"fullPreviewHash%sPath":"(.+?)"' % q m = re.search(pattern, self.html) - if m: + if m is not None: pyfile.name += ".mp4" self.link = m.group(1).replace("\\", "") return diff --git a/module/plugins/hoster/WebshareCz.py b/module/plugins/hoster/WebshareCz.py index 0009cc471..a11b59492 100644 --- a/module/plugins/hoster/WebshareCz.py +++ b/module/plugins/hoster/WebshareCz.py @@ -49,7 +49,7 @@ class WebshareCz(SimpleHoster): self.log_debug("API data: " + api_data) m = re.search('<link>(.+)</link>', api_data) - if m: + if m is not None: self.link = m.group(1) diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py index 8df1a441f..576451644 100644 --- a/module/plugins/hoster/XHamsterCom.py +++ b/module/plugins/hoster/XHamsterCom.py @@ -79,6 +79,7 @@ class XHamsterCom(Hoster): file_url = re.search(r"<a href=\"" + srv_url + "(.+?)\"", self.html) if file_url is None: self.error(_("file_url not found")) + file_url = file_url.group(1) long_url = srv_url + file_url self.log_debug("long_url = " + long_url) diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index aba66ee94..098143751 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -172,10 +172,10 @@ class Xdcc(Hoster): retry = time.time() + 300 if "you must be on a known channel to request a pack" in msg['text']: - self.fail(_("Wrong channel")) + self.fail(_("Invalid channel")) m = re.match('\x01DCC SEND (.*?) (\d+) (\d+)(?: (\d+))?\x01', msg['text']) - if m: + if m is not None: done = True #: Get connection data diff --git a/module/plugins/hoster/YadiSk.py b/module/plugins/hoster/YadiSk.py index a907cd282..354ba1b4c 100644 --- a/module/plugins/hoster/YadiSk.py +++ b/module/plugins/hoster/YadiSk.py @@ -34,7 +34,7 @@ class YadiSk(SimpleHoster): info ['idclient'] += random.choice('0123456abcdef') m = re.search(r'<script id="models-client" type="application/json">(.+?)</script>', html) - if m: + if m is not None: api_data = json_loads(m.group(1)) try: for sect in api_data: diff --git a/module/plugins/hoster/YourfilesTo.py b/module/plugins/hoster/YourfilesTo.py index a75bbcc94..cdf69afbe 100644 --- a/module/plugins/hoster/YourfilesTo.py +++ b/module/plugins/hoster/YourfilesTo.py @@ -41,7 +41,7 @@ class YourfilesTo(Hoster): #: var zzipitime = 15 m = re.search(r'var zzipitime = (\d+);', self.html) - if m: + if m is not None: sec = int(m.group(1)) else: sec = 0 |