diff options
Diffstat (limited to 'module/plugins')
62 files changed, 124 insertions, 117 deletions
diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/captcha/AdYouLike.py index d14babb51..d14babb51 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/captcha/AdYouLike.py diff --git a/module/plugins/internal/AdsCaptcha.py b/module/plugins/captcha/AdsCaptcha.py index f487042e2..da0c531be 100644 --- a/module/plugins/internal/AdsCaptcha.py +++ b/module/plugins/captcha/AdsCaptcha.py @@ -54,7 +54,7 @@ class AdsCaptcha(CaptchaService): def result(self, server, challenge): - result = self.decrypt_image("%sChallenge.aspx" % server, + result = self.decrypt("%sChallenge.aspx" % server, get={'cid': challenge, 'dummy': random.random()}, cookies=True, input_type="jpg") diff --git a/module/plugins/captcha/GigasizeCom.py b/module/plugins/captcha/GigasizeCom.py index 19ad9d680..f71266b23 100644 --- a/module/plugins/captcha/GigasizeCom.py +++ b/module/plugins/captcha/GigasizeCom.py @@ -14,7 +14,7 @@ class GigasizeCom(OCR): __authors__ = [("pyLoad Team", "admin@pyload.org")] - def get_captcha(self, image): + def recognize(self, image): self.load_image(image) self.threshold(2.8) self.run_tesser(True, False, False, True) diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index 68704f21d..0a4731375 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -137,7 +137,7 @@ class LinksaveIn(OCR): self.pixels = self.image.load() - def get_captcha(self, image): + def recognize(self, image): self.load_image(image) bg = self.get_bg() self.substract_bg(bg) diff --git a/module/plugins/captcha/NetloadIn.py b/module/plugins/captcha/NetloadIn.py index b6ba2b6e9..56b7c9196 100644 --- a/module/plugins/captcha/NetloadIn.py +++ b/module/plugins/captcha/NetloadIn.py @@ -14,7 +14,7 @@ class NetloadIn(OCR): __authors__ = [("pyLoad Team", "admin@pyload.org")] - def get_captcha(self, image): + def recognize(self, image): self.load_image(image) self.to_greyscale() self.clean(3) diff --git a/module/plugins/internal/ReCaptcha.py b/module/plugins/captcha/ReCaptcha.py index b4f9ef1eb..8f9755961 100644 --- a/module/plugins/internal/ReCaptcha.py +++ b/module/plugins/captcha/ReCaptcha.py @@ -85,7 +85,7 @@ class ReCaptcha(CaptchaService): get={'c': challenge}, cookies=True, input_type="jpg", - try_ocr=False) + ocr=False) self.log_debug("Result: %s" % result) @@ -170,10 +170,10 @@ class ReCaptcha(CaptchaService): self.log_debug("Token #3: %s" % token3.group(1)) millis_captcha_loading = int(round(time.time() * 1000)) - captcha_response = self.decrypt_image("https://www.google.com/recaptcha/api2/payload", + captcha_response = self.decrypt("https://www.google.com/recaptcha/api2/payload", get={'c':token3.group(1), 'k':key}, cookies=True, - try_ocr=False) + ocr=False) response = b64encode('{"response":"%s"}' % captcha_response) self.log_debug("Result: %s" % response) diff --git a/module/plugins/captcha/ShareonlineBiz.py b/module/plugins/captcha/ShareonlineBiz.py index 7f25f164d..98994b121 100644 --- a/module/plugins/captcha/ShareonlineBiz.py +++ b/module/plugins/captcha/ShareonlineBiz.py @@ -14,7 +14,7 @@ class ShareonlineBiz(OCR): __authors__ = [("RaNaN", "RaNaN@pyload.org")] - def get_captcha(self, image): + def recognize(self, image): self.load_image(image) self.to_greyscale() self.image = self.image.resize((160, 50)) diff --git a/module/plugins/internal/SolveMedia.py b/module/plugins/captcha/SolveMedia.py index ce4ebb007..cbac2dec2 100644 --- a/module/plugins/internal/SolveMedia.py +++ b/module/plugins/captcha/SolveMedia.py @@ -95,7 +95,7 @@ class SolveMedia(CaptchaService): def result(self, server, challenge): - result = self.decrypt_image(server, + result = self.decrypt(server, get={'c': challenge}, cookies=True, input_type="gif") diff --git a/module/plugins/crypter/DlProtectCom.py b/module/plugins/crypter/DlProtectCom.py index 4626af105..05efaca97 100644 --- a/module/plugins/crypter/DlProtectCom.py +++ b/module/plugins/crypter/DlProtectCom.py @@ -54,7 +54,7 @@ class DlProtectCom(SimpleCrypter): if "Security Code" in self.html: m = re.search(r'/captcha\.php\?key=(.+?)"', self.html) if m: - captcha_code = self.captcha.decrypt_image("http://www.dl-protect.com/captcha.php?key=" + m.group(1), input_type="gif") + captcha_code = self.captcha.decrypt("http://www.dl-protect.com/captcha.php?key=" + m.group(1), input_type="gif") post_req['secure'] = captcha_code self.html = self.load(self.pyfile.url, post=post_req) diff --git a/module/plugins/crypter/FilecryptCc.py b/module/plugins/crypter/FilecryptCc.py index 23636f3b7..3d0d089a7 100644 --- a/module/plugins/crypter/FilecryptCc.py +++ b/module/plugins/crypter/FilecryptCc.py @@ -10,7 +10,7 @@ import urlparse from Crypto.Cipher import AES from module.plugins.internal.Crypter import Crypter -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha class FilecryptCc(Crypter): @@ -92,16 +92,16 @@ class FilecryptCc(Crypter): if m: #: Normal captcha self.log_debug("Captcha-URL: %s" % m.group(1)) - captcha_code = self.captcha.decrypt_image(urlparse.urljoin(self.base_url, m.group(1)), + captcha_code = self.captcha.decrypt(urlparse.urljoin(self.base_url, m.group(1)), input_type="gif", - try_ocr=False) + ocr=False) self.site_with_links = self.load(self.pyfile.url, post={'recaptcha_response_field': captcha_code}) elif m2: #: Circle captcha self.log_debug("Captcha-URL: %s" % m2.group(1)) - captcha_code = self.captcha.decrypt_image('%s%s?c=abc' %(self.base_url, m2.group(1)), + captcha_code = self.captcha.decrypt('%s%s?c=abc' %(self.base_url, m2.group(1)), output_type='positional') self.site_with_links = self.load(self.pyfile.url, diff --git a/module/plugins/crypter/LinkCryptWs.py b/module/plugins/crypter/LinkCryptWs.py index baa440c51..8132db713 100644 --- a/module/plugins/crypter/LinkCryptWs.py +++ b/module/plugins/crypter/LinkCryptWs.py @@ -133,7 +133,7 @@ class LinkCryptWs(Crypter): def unlock_captcha_protection(self): captcha_url = re.search(r'<form.*?id\s*?=\s*?"captcha"[^>]*?>.*?<\s*?input.*?src="(.+?)"', self.html, re.I | re.S).group(1) - captcha_code = self.captcha.decrypt_image(captcha_url, input_type="gif", output_type='positional', try_ocr=False) + captcha_code = self.captcha.decrypt(captcha_url, input_type="gif", output_type='positional', ocr=False) self.html = self.load(self.pyfile.url, post={'x': captcha_code[0], 'y': captcha_code[1]}) diff --git a/module/plugins/crypter/LinkdecrypterCom.py b/module/plugins/crypter/LinkdecrypterCom.py index 1936425f2..de1172c6c 100644 --- a/module/plugins/crypter/LinkdecrypterCom.py +++ b/module/plugins/crypter/LinkdecrypterCom.py @@ -52,7 +52,7 @@ class LinkdecrypterCom(Crypter): msg = m.group(1) if m else "" self.log_info(_("Captcha protected link"), result_type, msg) - captcha = self.captcha.decrypt_image(captcha_url, output_type=result_type) + captcha = self.captcha.decrypt(captcha_url, output_type=result_type) if result_type == "positional": captcha = "%d|%d" % captcha self.html = self.load('http://linkdecrypter.com/', post={'captcha': captcha}) diff --git a/module/plugins/crypter/LixIn.py b/module/plugins/crypter/LixIn.py index 67037ae79..24b04a3e9 100644 --- a/module/plugins/crypter/LixIn.py +++ b/module/plugins/crypter/LixIn.py @@ -48,7 +48,7 @@ class LixIn(Crypter): m = re.search(self.CAPTCHA_PATTERN, self.html) if m: self.log_debug("Trying captcha") - captcharesult = self.captcha.decrypt_image(urlparse.urljoin("http://lix.in/", m.group(1))) + captcharesult = self.captcha.decrypt(urlparse.urljoin("http://lix.in/", m.group(1))) self.html = self.load(url, post={'capt': captcharesult, 'submit': "submit", 'tiny': id}) else: diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py index bc3f6624f..62b11612c 100644 --- a/module/plugins/crypter/NCryptIn.py +++ b/module/plugins/crypter/NCryptIn.py @@ -6,7 +6,7 @@ import re from Crypto.Cipher import AES from module.plugins.internal.Crypter import Crypter -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha class NCryptIn(Crypter): @@ -146,7 +146,7 @@ class NCryptIn(Crypter): if "anicaptcha" in form: self.log_debug("Captcha protected") captchaUri = re.search(r'src="(/temp/anicaptcha/.+?)"', form).group(1) - captcha = self.captcha.decrypt_image("http://ncrypt.in" + captchaUri) + captcha = self.captcha.decrypt("http://ncrypt.in" + captchaUri) self.log_debug("Captcha resolved [%s]" % captcha) postData['captcha'] = captcha @@ -164,7 +164,7 @@ class NCryptIn(Crypter): if "circlecaptcha" in form: self.log_debug("CircleCaptcha protected") captcha_img_url = "http://ncrypt.in/classes/captcha/circlecaptcha.php" - coords = self.captcha.decrypt_image(captcha_img_url, input_type="png", output_type='positional', try_ocr=False) + coords = self.captcha.decrypt(captcha_img_url, input_type="png", output_type='positional', ocr=False) self.log_debug("Captcha resolved, coords [%s]" % str(coords)) postData['circle.x'] = coords[0] postData['circle.y'] = coords[1] diff --git a/module/plugins/crypter/RelinkUs.py b/module/plugins/crypter/RelinkUs.py index f95da1b26..1d27f7c93 100644 --- a/module/plugins/crypter/RelinkUs.py +++ b/module/plugins/crypter/RelinkUs.py @@ -142,7 +142,7 @@ class RelinkUs(Crypter): def unlock_captcha_protection(self): self.log_debug("Request user positional captcha resolving") captcha_img_url = self.CAPTCHA_IMG_URL + "?id=%s" % self.fileid - coords = self.captcha.decrypt_image(captcha_img_url, input_type="png", output_type='positional', try_ocr=False) + coords = self.captcha.decrypt(captcha_img_url, input_type="png", output_type='positional', ocr=False) self.log_debug("Captcha resolved, coords [%s]" % str(coords)) captcha_post_url = self.CAPTCHA_SUBMIT_URL + "?id=%s" % self.fileid captcha_post_data = {'button.x': coords[0], 'button.y': coords[1], 'captcha': 'submit'} diff --git a/module/plugins/crypter/SafelinkingNet.py b/module/plugins/crypter/SafelinkingNet.py index 8dc833d03..e182df283 100644 --- a/module/plugins/crypter/SafelinkingNet.py +++ b/module/plugins/crypter/SafelinkingNet.py @@ -6,7 +6,7 @@ import BeautifulSoup from module.common.json_layer import json_loads from module.plugins.internal.Crypter import Crypter -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.SolveMedia import SolveMedia class SafelinkingNet(Crypter): diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index 894b6d010..82fc6285e 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -117,7 +117,7 @@ class ShareLinksBiz(Crypter): m = re.search(r'<img src="/captcha.gif\?d=(.*?)&PHPSESSID=(.*?)&legend=1"', self.html) captchaUrl = self.base_url + '/captcha.gif?d=%s&PHPSESSID=%s' % (m.group(1), m.group(2)) self.log_debug("Waiting user for correct position") - coords = self.captcha.decrypt_image(captchaUrl, input_type="gif", output_type='positional', try_ocr=False) + coords = self.captcha.decrypt(captchaUrl, input_type="gif", output_type='positional', ocr=False) self.log_debug("Captcha resolved, coords [%s]" % str(coords)) #: Resolve captcha diff --git a/module/plugins/hoster/BezvadataCz.py b/module/plugins/hoster/BezvadataCz.py index 523e87541..f332bc04b 100644 --- a/module/plugins/hoster/BezvadataCz.py +++ b/module/plugins/hoster/BezvadataCz.py @@ -48,7 +48,7 @@ class BezvadataCz(SimpleHoster): if m is None: self.error(_("Wrong captcha image")) - inputs['captcha'] = self.captcha.decrypt(m.group(1).decode('base64'), input_type='png') + inputs['captcha'] = self.captcha._decrypt(m.group(1).decode('base64'), input_type='png') if '<img src="data:image/png;base64' in self.html: self.captcha.invalid() diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index 7573c6e2a..39980b62f 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -4,7 +4,7 @@ from __future__ import with_statement import re -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/CatShareNet.py b/module/plugins/hoster/CatShareNet.py index 7f7437fe8..b1b4e2c3c 100644 --- a/module/plugins/hoster/CatShareNet.py +++ b/module/plugins/hoster/CatShareNet.py @@ -3,7 +3,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha class CatShareNet(SimpleHoster): diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py index 9b62a9f9e..cd21cc4b9 100644 --- a/module/plugins/hoster/CrockoCom.py +++ b/module/plugins/hoster/CrockoCom.py @@ -3,7 +3,7 @@ import re import urlparse -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index 71f217c94..57c3216cc 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -105,7 +105,7 @@ class CzshareCom(SimpleHoster): #: Get and decrypt captcha captcha_url = 'http://sdilej.cz/captcha.php' for _i in xrange(5): - inputs['captchastring2'] = self.captcha.decrypt_image(captcha_url) + 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: diff --git a/module/plugins/hoster/DateiTo.py b/module/plugins/hoster/DateiTo.py index 40725ff89..63e71e776 100644 --- a/module/plugins/hoster/DateiTo.py +++ b/module/plugins/hoster/DateiTo.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py index 02b334969..8c01d8756 100644 --- a/module/plugins/hoster/DepositfilesCom.py +++ b/module/plugins/hoster/DepositfilesCom.py @@ -3,7 +3,7 @@ import re import urllib -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/ExtabitCom.py b/module/plugins/hoster/ExtabitCom.py index 3b0367467..ca8a18096 100644 --- a/module/plugins/hoster/ExtabitCom.py +++ b/module/plugins/hoster/ExtabitCom.py @@ -4,7 +4,7 @@ import re from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, seconds_to_midnight diff --git a/module/plugins/hoster/FastshareCz.py b/module/plugins/hoster/FastshareCz.py index abe2ef2d6..13490441b 100644 --- a/module/plugins/hoster/FastshareCz.py +++ b/module/plugins/hoster/FastshareCz.py @@ -55,7 +55,7 @@ class FastshareCz(SimpleHoster): self.error(_("FREE_URL_PATTERN not found")) baseurl = "http://www.fastshare.cz" - captcha = self.captcha.decrypt_image(urlparse.urljoin(baseurl, captcha_src)) + captcha = self.captcha.decrypt(urlparse.urljoin(baseurl, captcha_src)) self.download(urlparse.urljoin(baseurl, action), post={'code': captcha, 'btn.x': 77, 'btn.y': 18}) diff --git a/module/plugins/hoster/FileSharkPl.py b/module/plugins/hoster/FileSharkPl.py index 901890433..d3fbd26d3 100644 --- a/module/plugins/hoster/FileSharkPl.py +++ b/module/plugins/hoster/FileSharkPl.py @@ -100,7 +100,7 @@ class FileSharkPl(SimpleHoster): if m is None: self.retry(reason=_("Captcha image not found")) - inputs['form[captcha]'] = self.captcha.decrypt(m.group(1).decode('base64'), input_type='jpeg') + inputs['form[captcha]'] = self.captcha._decrypt(m.group(1).decode('base64'), input_type='jpeg') inputs['form[start]'] = "" self.download(link, post=inputs, disposition=True) diff --git a/module/plugins/hoster/FileboomMe.py b/module/plugins/hoster/FileboomMe.py index 8d0f5d89c..a0b49d1bd 100644 --- a/module/plugins/hoster/FileboomMe.py +++ b/module/plugins/hoster/FileboomMe.py @@ -56,7 +56,7 @@ class FileboomMe(SimpleHoster): m = re.search(self.CAPTCHA_PATTERN, self.html) if m: - captcha = self.captcha.decrypt_image(urljoin(pyfile.url, m.group(1))) + captcha = self.captcha.decrypt(urljoin(pyfile.url, m.group(1))) self.html = self.load(post_url, post={'CaptchaForm[code]' : captcha, diff --git a/module/plugins/hoster/FilecloudIo.py b/module/plugins/hoster/FilecloudIo.py index d010af624..4383f27d4 100644 --- a/module/plugins/hoster/FilecloudIo.py +++ b/module/plugins/hoster/FilecloudIo.py @@ -3,7 +3,7 @@ import re from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/FiledropperCom.py b/module/plugins/hoster/FiledropperCom.py index dede02dac..930b7efdb 100644 --- a/module/plugins/hoster/FiledropperCom.py +++ b/module/plugins/hoster/FiledropperCom.py @@ -34,7 +34,7 @@ class FiledropperCom(SimpleHoster): if m is None: self.fail("Captcha not found") - captcha_code = self.captcha.decrypt_image("http://www.filedropper.com/%s" % m.group(1)) + 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: diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index bc2278a41..de15baab8 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -4,7 +4,7 @@ import re import time from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index 61b3a9635..26420f294 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -8,7 +8,7 @@ import pycurl import re import urlparse -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index 117ee1f4c..60df758f5 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -6,7 +6,7 @@ from module.common.json_layer import json_loads from module.network.RequestFactory import getURL as get_url from module.plugins.internal.Hoster import Hoster from module.plugins.internal.Plugin import chunks -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import seconds_to_midnight from module.utils import parseFileSize as parse_size diff --git a/module/plugins/hoster/FreakshareCom.py b/module/plugins/hoster/FreakshareCom.py index ba088027a..a80c71b67 100644 --- a/module/plugins/hoster/FreakshareCom.py +++ b/module/plugins/hoster/FreakshareCom.py @@ -3,7 +3,7 @@ import re from module.plugins.internal.Hoster import Hoster -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import seconds_to_midnight diff --git a/module/plugins/hoster/GigapetaCom.py b/module/plugins/hoster/GigapetaCom.py index 3fcf4ee32..0334087d3 100644 --- a/module/plugins/hoster/GigapetaCom.py +++ b/module/plugins/hoster/GigapetaCom.py @@ -39,7 +39,7 @@ class GigapetaCom(SimpleHoster): for _i in xrange(5): self.check_errors() - captcha = self.captcha.decrypt_image(captcha_url) + captcha = self.captcha.decrypt(captcha_url) self.html = self.load(pyfile.url, post={ 'captcha_key': captcha_key, 'captcha': captcha, diff --git a/module/plugins/hoster/IfolderRu.py b/module/plugins/hoster/IfolderRu.py index 457bd6962..f289e29b5 100644 --- a/module/plugins/hoster/IfolderRu.py +++ b/module/plugins/hoster/IfolderRu.py @@ -49,7 +49,7 @@ class IfolderRu(SimpleHoster): 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_image(captcha_url, cookies=True) + inputs['confirmed_number'] = self.captcha.decrypt(captcha_url, cookies=True) inputs['action'] = '1' self.log_debug(inputs) diff --git a/module/plugins/hoster/Keep2ShareCc.py b/module/plugins/hoster/Keep2ShareCc.py index 4fa3f121f..41538da94 100644 --- a/module/plugins/hoster/Keep2ShareCc.py +++ b/module/plugins/hoster/Keep2ShareCc.py @@ -3,7 +3,7 @@ import re import urlparse -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -101,7 +101,7 @@ class Keep2ShareCc(SimpleHoster): self.log_debug("CAPTCHA_PATTERN found %s" % m) if m: captcha_url = urlparse.urljoin("http://keep2s.cc/", m.group(1)) - post_data['CaptchaForm[code]'] = self.captcha.decrypt_image(captcha_url) + post_data['CaptchaForm[code]'] = self.captcha.decrypt(captcha_url) else: recaptcha = ReCaptcha(self) response, challenge = recaptcha.challenge() diff --git a/module/plugins/hoster/KingfilesNet.py b/module/plugins/hoster/KingfilesNet.py index d05d8443a..b02b26914 100644 --- a/module/plugins/hoster/KingfilesNet.py +++ b/module/plugins/hoster/KingfilesNet.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 92bb5ab62..59d1ae41b 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -11,7 +11,7 @@ import urlparse from module.common.json_layer import json_loads, json_dumps from module.network.RequestFactory import getURL as get_url -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, seconds_to_midnight diff --git a/module/plugins/hoster/LoadTo.py b/module/plugins/hoster/LoadTo.py index 2ce9134a2..e8f8cbf9a 100644 --- a/module/plugins/hoster/LoadTo.py +++ b/module/plugins/hoster/LoadTo.py @@ -6,7 +6,7 @@ import re -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index e5ae3f1c3..d71c0d9d7 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -3,7 +3,7 @@ import re from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index bbe9aeb77..cc3c6a6a4 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.ReCaptcha import ReCaptcha -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.ReCaptcha import ReCaptcha +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index 65c41c23f..46c4cba91 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -56,7 +56,7 @@ class MegasharesCom(SimpleHoster): for _i in xrange(5): random_num = re.search(self.REACTIVATE_NUM_PATTERN, self.html).group(1) - verifyinput = self.captcha.decrypt_image("http://d01.megashares.com/index.php", + 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)) diff --git a/module/plugins/hoster/NarodRu.py b/module/plugins/hoster/NarodRu.py index f54fbf71e..a833edff4 100644 --- a/module/plugins/hoster/NarodRu.py +++ b/module/plugins/hoster/NarodRu.py @@ -43,7 +43,7 @@ class NarodRu(SimpleHoster): post_data = {'action': "sendcapcha"} captcha_url, post_data['key'] = m.groups() - post_data['rep'] = self.captcha.decrypt_image(captcha_url) + post_data['rep'] = self.captcha.decrypt(captcha_url) self.html = self.load(pyfile.url, post=post_data) diff --git a/module/plugins/hoster/NitroflareCom.py b/module/plugins/hoster/NitroflareCom.py index c03cb8de0..54b243e3c 100644 --- a/module/plugins/hoster/NitroflareCom.py +++ b/module/plugins/hoster/NitroflareCom.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster diff --git a/module/plugins/hoster/OboomCom.py b/module/plugins/hoster/OboomCom.py index f5624439f..43eb726be 100644 --- a/module/plugins/hoster/OboomCom.py +++ b/module/plugins/hoster/OboomCom.py @@ -7,7 +7,7 @@ import re from module.common.json_layer import json_loads from module.plugins.internal.Hoster import Hoster -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha class OboomCom(Hoster): diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py index 7b364e150..8aa513775 100644 --- a/module/plugins/hoster/RapidgatorNet.py +++ b/module/plugins/hoster/RapidgatorNet.py @@ -5,9 +5,9 @@ import re from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader -from module.plugins.internal.AdsCaptcha import AdsCaptcha -from module.plugins.internal.ReCaptcha import ReCaptcha -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.AdsCaptcha import AdsCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/RapiduNet.py b/module/plugins/hoster/RapiduNet.py index 9c1670211..a4afc99e4 100644 --- a/module/plugins/hoster/RapiduNet.py +++ b/module/plugins/hoster/RapiduNet.py @@ -5,7 +5,7 @@ import re import time from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/SendspaceCom.py b/module/plugins/hoster/SendspaceCom.py index 18e66033f..46cc83824 100644 --- a/module/plugins/hoster/SendspaceCom.py +++ b/module/plugins/hoster/SendspaceCom.py @@ -48,7 +48,7 @@ class SendspaceCom(SimpleHoster): captcha_url2 = "http://www.sendspace.com/" + m.group(1) params = {'captcha_hash': m.group(2), 'captcha_submit': 'Verify', - 'captcha_answer': self.captcha.decrypt_image(captcha_url1) + " " + self.captcha.decrypt_image(captcha_url2)} + 'captcha_answer': self.captcha.decrypt(captcha_url1) + " " + self.captcha.decrypt(captcha_url2)} else: params = {'download': "Regular Download"} diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 13e4f8f87..801057b66 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -6,7 +6,7 @@ import urllib import urlparse from module.network.RequestFactory import getURL as get_url -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py index f70a985df..1d47f9329 100644 --- a/module/plugins/hoster/TurbobitNet.py +++ b/module/plugins/hoster/TurbobitNet.py @@ -9,7 +9,7 @@ import urllib from Crypto.Cipher import ARC4 -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp @@ -81,7 +81,7 @@ class TurbobitNet(SimpleHoster): if m is None: self.error(_("captcha")) captcha_url = m.group(1) - inputs['captcha_response'] = self.captcha.decrypt_image(captcha_url) + inputs['captcha_response'] = self.captcha.decrypt(captcha_url) self.log_debug(inputs) self.html = self.load(self.url, post=inputs) diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 27b5843d9..1cd4ec853 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -60,7 +60,7 @@ class UlozTo(SimpleHoster): #: Old version - last seen 9.12.2013 self.log_debug('Using "old" version') - captcha_value = self.captcha.decrypt_image("http://img.uloz.to/captcha/%s.png" % inputs['captcha_id']) + captcha_value = self.captcha.decrypt("http://img.uloz.to/captcha/%s.png" % inputs['captcha_id']) self.log_debug("CAPTCHA ID: " + inputs['captcha_id'] + ", CAPTCHA VALUE: " + captcha_value) inputs.update({'captcha_id': inputs['captcha_id'], 'captcha_key': inputs['captcha_key'], 'captcha_value': captcha_value}) @@ -73,7 +73,7 @@ class UlozTo(SimpleHoster): self.log_debug("xapca = " + str(xapca)) data = json_loads(xapca) - captcha_value = self.captcha.decrypt_image(str(data['image'])) + captcha_value = self.captcha.decrypt(str(data['image'])) self.log_debug("CAPTCHA HASH: " + data['hash'], "CAPTCHA SALT: " + str(data['salt']), "CAPTCHA VALUE: " + captcha_value) inputs.update({'timestamp': data['timestamp'], 'salt': data['salt'], 'hash': data['hash'], 'captcha_value': captcha_value}) diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index 58e3b685a..69adedeb1 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -59,7 +59,7 @@ class UloziskoSk(SimpleHoster): self.error(_("CAPTCHA_PATTERN not found")) captcha_url = urlparse.urljoin("http://www.ulozisko.sk", m.group(1)) - captcha = self.captcha.decrypt_image(captcha_url, cookies=True) + captcha = self.captcha.decrypt(captcha_url, cookies=True) self.log_debug("CAPTCHA_URL:" + captcha_url + ' CAPTCHA:' + captcha) diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index 96b2fb031..1c1a0bd2b 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -65,7 +65,7 @@ class UnibytesCom(SimpleHoster): self.wait(m.group(1) if m else 60, False) elif last_step in ("captcha", "last"): - post_data['captcha'] = self.captcha.decrypt_image(urlparse.urljoin(domain, "/captcha.jpg")) + post_data['captcha'] = self.captcha.decrypt(urlparse.urljoin(domain, "/captcha.jpg")) else: self.fail(_("No valid captcha code entered")) diff --git a/module/plugins/hoster/UploadableCh.py b/module/plugins/hoster/UploadableCh.py index 5b2eed554..7d3a6952a 100644 --- a/module/plugins/hoster/UploadableCh.py +++ b/module/plugins/hoster/UploadableCh.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index c5f3cd8ad..f77c6a483 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -5,7 +5,7 @@ import time import urlparse from module.network.RequestFactory import getURL as get_url -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/UploadheroCom.py b/module/plugins/hoster/UploadheroCom.py index 8a0b3a032..69318fb4b 100644 --- a/module/plugins/hoster/UploadheroCom.py +++ b/module/plugins/hoster/UploadheroCom.py @@ -44,7 +44,7 @@ class UploadheroCom(SimpleHoster): if m is None: self.error(_("Captcha not found")) - captcha = self.captcha.decrypt_image(urlparse.urljoin("http://uploadhero.co", m.group(1))) + captcha = self.captcha.decrypt(urlparse.urljoin("http://uploadhero.co", m.group(1))) self.html = self.load(pyfile.url, get={'code': captcha}) diff --git a/module/plugins/hoster/UpstoreNet.py b/module/plugins/hoster/UpstoreNet.py index 49578aafe..21c359cc2 100644 --- a/module/plugins/hoster/UpstoreNet.py +++ b/module/plugins/hoster/UpstoreNet.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 7df13a075..aa64c1903 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -5,7 +5,7 @@ import urllib import BeautifulSoup -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py index af7f66ed5..942021f26 100644 --- a/module/plugins/internal/Captcha.py +++ b/module/plugins/internal/Captcha.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- +import time + from module.plugins.internal.Plugin import Plugin class Captcha(Plugin): __name__ = "Captcha" __type__ = "captcha" - __version__ = "0.01" + __version__ = "0.02" __status__ = "stable" __description__ = """Base anti-captcha plugin""" @@ -35,13 +37,21 @@ class Captcha(Plugin): pass - def decrypt_image(self, url, get={}, post={}, ref=False, cookies=False, decode=False, - input_type='png', output_type='textual', try_ocr=True): - image = self.load(url, get=get, post=post, ref=ref, cookies=cookies, decode=decode) - return self.decrypt(image, input_type, output_type, try_ocr) + def recognize(self, image): + """ + Extend to build your custom anti-captcha ocr + """ + pass + + + def decrypt(self, url, get={}, post={}, ref=False, cookies=False, decode=False, + input_type='png', output_type='textual', ocr=True): + img = self.load(url, get=get, post=post, ref=ref, cookies=cookies, decode=decode) + return self._decrypt(img, input_type, output_type, ocr) - def decrypt(self, data, input_type='png', output_type='textual', try_ocr=True): + #@TODO: Definitely dhoose a better name for this method! + def _decrypt(self, raw, input_type='png', output_type='textual', ocr=None): """ Loads a captcha and decrypts it with ocr, plugin, user input @@ -53,56 +63,53 @@ class Captcha(Plugin): :param output_type: 'textual' if text is written on the captcha\ or 'positional' for captcha where the user have to click\ on a specific region on the captcha - :param try_ocr: if True, ocr is not used + :param ocr: if True, ocr is not used :return: result of decrypting """ - id = ("%.2f" % time.time())[-6:].replace(".", "") + time_ref = ("%.2f" % time.time())[-6:].replace(".", "") + + with open(os.path.join("tmp", "captcha_image_%s_%s.%s" % (self.plugin.__name__, time_ref, input_type)), "wb") as tmp_img: + tmp_img.write(raw) + + if ocr is not False: + if isinstance(ocr, basestring): + OCR = self.pyload.pluginManager.loadClass("captcha", ocr) #: Rename `captcha` to `ocr` in 0.4.10 - with open(os.path.join("tmp", "tmpCaptcha_%s_%s.%s" % (self.plugin.__name__, id, input_type)), "wb") as tmpCaptcha: - tmpCaptcha.write(img) + if self.plugin.pyfile.abort: + self.abort() - has_plugin = self.plugin.__name__ in self.pyload.pluginManager.ocrPlugins + result = OCR(self.plugin.pyfile).recognize(tmp_img.name) - if self.pyload.captcha: - Ocr = self.pyload.pluginManager.loadClass("ocr", self.plugin.__name__) - else: - Ocr = None + else: + result = self.recognize(tmp_img.name) - if Ocr and try_ocr: - time.sleep(random.randint(3000, 5000) / 1000.0) - if self.pyfile.abort: - self.abort() + else: + captchaManager = self.pyload.captchaManager - ocr = Ocr(self.pyfile) - result = ocr.get_captcha(tmpCaptcha.name) - else: - captchaManager = self.pyload.captchaManager - task = captchaManager.newTask(img, input_type, tmpCaptcha.name, output_type) - self.task = task - captchaManager.handleCaptcha(task) + try: + self.task = captchaManager.newTask(img, input_type, tmp_img.name, output_type) + captchaManager.handleCaptcha(self.task) - while task.isWaiting(): - if self.pyfile.abort: - captchaManager.removeTask(task) - self.abort() - time.sleep(1) + while self.task.isWaiting(): + if self.plugin.pyfile.abort: + self.abort() + time.sleep(1) + finally: + captchaManager.removeTask(self.task) - captchaManager.removeTask(task) + if self.task.error: + self.fail(task.error) - if task.error and has_plugin: #: Ignore default error message since the user could use try_ocr - self.fail(_("Pil and tesseract not installed and no Client connected for captcha decrypting")) - elif task.error: - self.fail(task.error) - elif not task.result: - self.fail(_("No captcha result obtained in appropiate time by any of the plugins")) + elif not self.task.result: + self.fail(_("No captcha result obtained in appropiate time by any of the plugins")) - result = task.result - self.log_debug("Received captcha result: %s" % result) + result = task.result + self.log_debug("Received captcha result: %s" % result) #@TODO: Remove from here? if not self.pyload.debug: try: - os.remove(tmpCaptcha.name) + os.remove(tmp_img.name) except Exception: pass diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py index ee5571f77..5c22866c8 100644 --- a/module/plugins/internal/OCR.py +++ b/module/plugins/internal/OCR.py @@ -20,7 +20,7 @@ from module.utils import save_join as fs_join class OCR(Plugin): __name__ = "OCR" __type__ = "ocr" - __version__ = "0.12" + __version__ = "0.13" __status__ = "stable" __description__ = """OCR base plugin""" @@ -133,7 +133,7 @@ class OCR(Plugin): pass - def get_captcha(self, name): + def recognize(self, name): raise NotImplementedError diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index ec9a18a48..18a50a6b0 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -4,8 +4,8 @@ import pycurl import random import re -from module.plugins.internal.ReCaptcha import ReCaptcha -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.ReCaptcha import ReCaptcha +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, seconds_to_midnight from module.utils import html_unescape @@ -221,7 +221,7 @@ class XFSHoster(SimpleHoster): m = re.search(self.CAPTCHA_PATTERN, self.html) if m: captcha_url = m.group(1) - inputs['code'] = self.captcha.decrypt_image(captcha_url) + inputs['code'] = self.captcha.decrypt(captcha_url) return m = re.search(self.CAPTCHA_BLOCK_PATTERN, self.html, re.S) |