diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-12-14 16:08:07 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-12-27 21:19:38 +0100 |
commit | 299a26f5422f7309dafb30a6876e0c5d164bf92c (patch) | |
tree | 2ac7a1937f096334edbf8011bcd015d88d0307bc /module/plugins | |
parent | Rewrite utils (1) (diff) | |
download | pyload-299a26f5422f7309dafb30a6876e0c5d164bf92c.tar.xz |
Update captchas
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/captcha/AdYouLike.py | 6 | ||||
-rw-r--r-- | module/plugins/captcha/AdsCaptcha.py | 4 | ||||
-rw-r--r-- | module/plugins/captcha/CircleCaptcha.py | 74 | ||||
-rw-r--r-- | module/plugins/captcha/GigasizeCom.py | 2 | ||||
-rw-r--r-- | module/plugins/captcha/LinksaveIn.py | 2 | ||||
-rw-r--r-- | module/plugins/captcha/NetloadIn.py | 2 | ||||
-rw-r--r-- | module/plugins/captcha/ReCaptcha.py | 27 | ||||
-rw-r--r-- | module/plugins/captcha/ShareonlineBiz.py | 2 | ||||
-rw-r--r-- | module/plugins/captcha/SolveMedia.py | 12 |
9 files changed, 65 insertions, 66 deletions
diff --git a/module/plugins/captcha/AdYouLike.py b/module/plugins/captcha/AdYouLike.py index c374c5bcf..c21a3d4fa 100644 --- a/module/plugins/captcha/AdYouLike.py +++ b/module/plugins/captcha/AdYouLike.py @@ -2,14 +2,14 @@ import re -from module.plugins.internal.utils import json +from module.plugins.internal.misc import json from module.plugins.internal.CaptchaService import CaptchaService class AdYouLike(CaptchaService): __name__ = "AdYouLike" __type__ = "captcha" - __version__ = "0.08" + __version__ = "0.09" __status__ = "testing" __description__ = """AdYouLike captcha service plugin""" @@ -42,7 +42,7 @@ class AdYouLike(CaptchaService): #: 'all':{'element_id':"ayl_private_cap_92300",'lang':"fr",'env':"prod"}} ayl = json.loads(ayl) - html = self.plugin.load("http://api-ayl.appspot.com/challenge", + html = self.pyfile.plugin.load("http://api-ayl.appspot.com/challenge", get={'key' : ayl['adyoulike']['key'], 'env' : ayl['all']['env'], 'callback': callback}) diff --git a/module/plugins/captcha/AdsCaptcha.py b/module/plugins/captcha/AdsCaptcha.py index e8c578e96..234d2a0cf 100644 --- a/module/plugins/captcha/AdsCaptcha.py +++ b/module/plugins/captcha/AdsCaptcha.py @@ -9,7 +9,7 @@ from module.plugins.internal.CaptchaService import CaptchaService class AdsCaptcha(CaptchaService): __name__ = "AdsCaptcha" __type__ = "captcha" - __version__ = "0.11" + __version__ = "0.12" __status__ = "testing" __description__ = """AdsCaptcha captcha service plugin""" @@ -38,7 +38,7 @@ class AdsCaptcha(CaptchaService): def challenge(self, key=None, data=None): PublicKey, CaptchaId = key or self.retrieve_key(data) - html = self.plugin.load("http://api.adscaptcha.com/Get.aspx", + html = self.pyfile.plugin.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) try: diff --git a/module/plugins/captcha/CircleCaptcha.py b/module/plugins/captcha/CircleCaptcha.py index 98e54e5ed..482779321 100644 --- a/module/plugins/captcha/CircleCaptcha.py +++ b/module/plugins/captcha/CircleCaptcha.py @@ -31,7 +31,7 @@ class ImageSequence: class CircleCaptcha(OCR): __name__ = "CircleCaptcha" __type__ = "ocr" - __version__ = "1.05" + __version__ = "1.06" __status__ = "testing" __description__ = """Circle captcha ocr plugin""" @@ -71,7 +71,7 @@ class CircleCaptcha(OCR): curcolor = curpix # self.log_debug(x, y, jump, 2) else: - if howmany == 0: + if howmany is 0: #: Found pixel jump = True howmany = howmany + 1 @@ -79,7 +79,7 @@ class CircleCaptcha(OCR): # self.log_debug(x, y, jump, 2) else: howmany = howmany + 1 - if howmany == 1: + if howmany is 1: #: Clean pixel pix[x-1, y] = self.BACKGROUND @@ -102,7 +102,7 @@ class CircleCaptcha(OCR): curcolor = curpix # self.log_debug(x, y, jump) else: - if howmany == 0: + if howmany is 0: #: Found pixel jump = True howmany = howmany + 1 @@ -110,7 +110,7 @@ class CircleCaptcha(OCR): # self.log_debug(x, y, jump) else: howmany = howmany + 1 - if howmany == 1: + if howmany is 1: #: Clean pixel pix[x-1, y] = self.BACKGROUND @@ -277,19 +277,19 @@ class CircleCaptcha(OCR): return -2 cardinalpoints = 0 - if self.verify_point(im, pix, c[0] + c[2], c[1], True) == 1: + if self.verify_point(im, pix, c[0] + c[2], c[1], True) is 1: cardinalpoints = cardinalpoints + 1 if self.verify_point(im, pix, c[0] + c[2], c[1], False) == -1: return -2 - if self.verify_point(im, pix, c[0] - c[2], c[1], True) == 1: + if self.verify_point(im, pix, c[0] - c[2], c[1], True) is 1: cardinalpoints = cardinalpoints + 1 if self.verify_point(im, pix, c[0] - c[2], c[1], False) == -1: return -2 - if self.verify_point(im, pix, c[0], c[1] + c[2], True) == 1: + if self.verify_point(im, pix, c[0], c[1] + c[2], True) is 1: cardinalpoints = cardinalpoints + 1 if self.verify_point(im, pix, c[0], c[1] + c[2], False) == -1: return -2 - if self.verify_point(im, pix, c[0], c[1] - c[2], True) == 1: + if self.verify_point(im, pix, c[0], c[1] - c[2], True) is 1: cardinalpoints = cardinalpoints + 1 if self.verify_point(im, pix, c[0], c[1] - c[2], False) == -1: return -2 @@ -302,7 +302,7 @@ class CircleCaptcha(OCR): y2= int(round(c[1]+ math.sqrt(c[2]**2-(c[0]-x)**2))) howmany = howmany + 2 - if self.verify_point(im, pix, x, y, exactfind) == 0: + if self.verify_point(im, pix, x, y, exactfind) is 0: missing = missing + 1 missinglist.append((x, y)) else: @@ -311,7 +311,7 @@ class CircleCaptcha(OCR): if self.verify_point(im, pix, x, y, False) == -1: return -2 - if self.verify_point(im, pix, x, y2, exactfind) == 0: + if self.verify_point(im, pix, x, y2, exactfind) is 0: missing = missing + 1 missinglist.append((x, y2)) else: @@ -363,19 +363,19 @@ class CircleCaptcha(OCR): return -2 cardinalpoints = 0 - if self.verify_point(im, pix, c[0] + c[2], c[1], True) == 1: + if self.verify_point(im, pix, c[0] + c[2], c[1], True) is 1: cardinalpoints = cardinalpoints + 1 if self.verify_point(im, pix, c[0] + c[2], c[1], False) == -1: return -2 - if self.verify_point(im, pix, c[0] - c[2], c[1], True) == 1: + if self.verify_point(im, pix, c[0] - c[2], c[1], True) is 1: cardinalpoints = cardinalpoints + 1 if self.verify_point(im, pix, c[0] - c[2], c[1], False) == -1: return -2 - if self.verify_point(im, pix, c[0], c[1] + c[2], True) == 1: + if self.verify_point(im, pix, c[0], c[1] + c[2], True) is 1: cardinalpoints = cardinalpoints + 1 if self.verify_point(im, pix, c[0], c[1] + c[2], False) == -1: return -2 - if self.verify_point(im, pix, c[0], c[1] - c[2], True) == 1: + if self.verify_point(im, pix, c[0], c[1] - c[2], True) is 1: cardinalpoints = cardinalpoints + 1 if self.verify_point(im, pix, c[0], c[1] - c[2], False) == -1: return -2 @@ -388,7 +388,7 @@ class CircleCaptcha(OCR): y2= int(round(c[1]+ math.sqrt(c[2]**2-(c[0]-x)**2))) howmany = howmany + 2 - if self.verify_point(im, pix, x, y, exactfind) == 0: + if self.verify_point(im, pix, x, y, exactfind) is 0: missing = missing + 1 missinglist.append((x, y)) else: @@ -397,7 +397,7 @@ class CircleCaptcha(OCR): if self.verify_point(im, pix, x, y, False) == -1: return -2 - if self.verify_point(im, pix, x, y2, exactfind) == 0: + if self.verify_point(im, pix, x, y2, exactfind) is 0: missing = missing + 1 missinglist.append((x, y2)) else: @@ -412,7 +412,7 @@ class CircleCaptcha(OCR): x2= int(round(c[0]+ math.sqrt(c[2]**2-(c[1]-y)**2))) howmany = howmany + 2 - if self.verify_point(im, pix, x, y, exactfind) == 0: + if self.verify_point(im, pix, x, y, exactfind) is 0: missing = missing + 1 missinglist.append((x, y)) else: @@ -421,7 +421,7 @@ class CircleCaptcha(OCR): if self.verify_point(im, pix, x, y, False) == -1: return -2 - if self.verify_point(im, pix, x2, y, exactfind) == 0: + if self.verify_point(im, pix, x2, y, exactfind) is 0: missing = missing + 1 missinglist.append((x2, y)) else: @@ -432,19 +432,19 @@ class CircleCaptcha(OCR): for p in missinglist: #: Left and bottom - if (self.verify_point(im, pix, p[0]-1, p[1], exactfind) == 1 - and self.verify_point(im, pix, p[0], p[1]+1, exactfind) == 1): + if (self.verify_point(im, pix, p[0]-1, p[1], exactfind) is 1 + and self.verify_point(im, pix, p[0], p[1]+1, exactfind) is 1): missing = missing - 1 - elif (self.verify_point(im, pix, p[0]-1, p[1], exactfind) == 1 - and self.verify_point(im, pix, p[0], p[1]-1, exactfind) == 1): + elif (self.verify_point(im, pix, p[0]-1, p[1], exactfind) is 1 + and self.verify_point(im, pix, p[0], p[1]-1, exactfind) is 1): missing = missing - 1 #: Right and bottom - elif (self.verify_point(im, pix, p[0]+1, p[1], exactfind) == 1 - and self.verify_point(im, pix, p[0], p[1]+1, exactfind) == 1): + elif (self.verify_point(im, pix, p[0]+1, p[1], exactfind) is 1 + and self.verify_point(im, pix, p[0], p[1]+1, exactfind) is 1): missing = missing - 1 #: Right and up - elif (self.verify_point(im, pix, p[0]+1, p[1], exactfind) == 1 - and self.verify_point(im, pix, p[0], p[1]-1, exactfind) == 1): + elif (self.verify_point(im, pix, p[0]+1, p[1], exactfind) is 1 + and self.verify_point(im, pix, p[0], p[1]-1, exactfind) is 1): missing = missing - 1 if ((p[0], p[1]+1) in missinglist @@ -455,7 +455,7 @@ class CircleCaptcha(OCR): or (p[0]-1, p[1]+1) in missinglist or (p[0]+1, p[1]-1) in missinglist or (p[0]-1, p[1]-1) in missinglist - or self.verify_point(im, pix, p[0], p[1], False) == 1): + or self.verify_point(im, pix, p[0], p[1], False) is 1): missingconsecutive = missingconsecutive + 1 # else: # pix[p[0], p[1]] = 0 @@ -501,7 +501,7 @@ class CircleCaptcha(OCR): howmany < 80: return -1 # elif missing / howmany < 0.10: - elif missing == 0: + elif missing is 0: self.pointsofcirclefound.extend(pointsofcircle) return 1 elif (missing - missingconsecutive) / howmany < 0.20: @@ -641,7 +641,7 @@ class CircleCaptcha(OCR): x3 = math.floor(x2 - ((x2 - x1) / 2)) y3 = y1 for j in xrange(1, 50): - retval = self.find_last_pixel_y(im, pix, x3, y3, True if invert == 1 else False, -1, True) + retval = self.find_last_pixel_y(im, pix, x3, y3, True if invert is 1 else False, -1, True) # self.log_debug(x3, y3, retval[0], invert) y3 = retval[0] if y3 == -2: @@ -675,10 +675,10 @@ class CircleCaptcha(OCR): if verified == -1: verified = -1 - elif verified == 0: + elif verified is 0: found.add(((c[0], c[1], c[2]), verified)) findnewcircle = True - elif verified == 1: + elif verified is 1: found.add(((c[0], c[1], c[2]), verified)) findnewcircle = True @@ -688,11 +688,11 @@ class CircleCaptcha(OCR): # draw.ellipse((c[0]-c[2], c[1]-c[2], c[0]+c[2], c[1]+c[2]), outline=0) # _pause = "NOTDOUND" # imdebug.save("debug.png", "png") - if verified == 0: + if verified is 0: draw.ellipse((c[0]-c[2], c[1]-c[2], c[0]+c[2], c[1]+c[2]), outline=120) _pause = "OPENED" - if verified == 1: + if verified is 1: draw.ellipse((c[0]-c[2], c[1]-c[2], c[0]+c[2], c[1]+c[2]), outline=65) _pause = "CLOSED" @@ -716,7 +716,7 @@ class CircleCaptcha(OCR): #: Clean results for c in found: verify = c[1] - if verify == 0: + if verify is 0: p = c[0] if (((p[0], p[1]+1, p[2]), 1) in found or ((p[0], p[1]-1, p[2]), 1) in found @@ -752,12 +752,12 @@ class CircleCaptcha(OCR): #: Delete nearly circle verify = -1 - # if verify == 0: + # if verify is 0: # if self.pyload.debug: # pix[c[0][0], c[0][1]] = 90 #(255, 255, 0) # im.save("output.png", "png") # return c[0][0], c[0][1] - # elif verify == 1: + # elif verify is 1: # if self.pyload.debug: # pix[c[0][0], c[0][1]] = 40 #(255, 0, 0) # im.save("output.png", "png") diff --git a/module/plugins/captcha/GigasizeCom.py b/module/plugins/captcha/GigasizeCom.py index bcaceee03..c870ac6a7 100644 --- a/module/plugins/captcha/GigasizeCom.py +++ b/module/plugins/captcha/GigasizeCom.py @@ -6,7 +6,7 @@ from module.plugins.internal.OCR import OCR class GigasizeCom(OCR): __name__ = "GigasizeCom" __type__ = "ocr" - __version__ = "0.15" + __version__ = "0.16" __status__ = "testing" __description__ = """Gigasize.com ocr plugin""" diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index 283d9f6eb..27d1898bb 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -15,7 +15,7 @@ from module.plugins.internal.OCR import OCR class LinksaveIn(OCR): __name__ = "LinksaveIn" __type__ = "ocr" - __version__ = "0.15" + __version__ = "0.16" __status__ = "testing" __description__ = """Linksave.in ocr plugin""" diff --git a/module/plugins/captcha/NetloadIn.py b/module/plugins/captcha/NetloadIn.py index a7b2131c1..b1a9d7027 100644 --- a/module/plugins/captcha/NetloadIn.py +++ b/module/plugins/captcha/NetloadIn.py @@ -6,7 +6,7 @@ from module.plugins.internal.OCR import OCR class NetloadIn(OCR): __name__ = "NetloadIn" __type__ = "ocr" - __version__ = "0.15" + __version__ = "0.16" __status__ = "testing" __description__ = """Netload.in ocr plugin""" diff --git a/module/plugins/captcha/ReCaptcha.py b/module/plugins/captcha/ReCaptcha.py index e2bd5e8ca..b30f110d4 100644 --- a/module/plugins/captcha/ReCaptcha.py +++ b/module/plugins/captcha/ReCaptcha.py @@ -1,19 +1,18 @@ # -*- coding: utf-8 -*- +import base64 import random import re import time import urlparse -from base64 import b64encode - from module.plugins.internal.CaptchaService import CaptchaService class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" __type__ = "captcha" - __version__ = "0.19" + __version__ = "0.20" __status__ = "testing" __description__ = """ReCaptcha captcha service plugin""" @@ -52,7 +51,7 @@ class ReCaptcha(CaptchaService): def _challenge_v1(self, key): - html = self.plugin.load("http://www.google.com/recaptcha/api/challenge", + html = self.pyfile.plugin.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) try: challenge = re.search("challenge : '(.+?)',", html).group(1) @@ -67,8 +66,8 @@ class ReCaptcha(CaptchaService): def result(self, server, challenge, key): - self.plugin.load("http://www.google.com/recaptcha/api/js/recaptcha.js") - html = self.plugin.load("http://www.google.com/recaptcha/api/reload", + self.pyfile.plugin.load("http://www.google.com/recaptcha/api/js/recaptcha.js") + html = self.pyfile.plugin.load("http://www.google.com/recaptcha/api/reload", get={'c' : challenge, 'k' : key, 'reason': "i", @@ -92,7 +91,7 @@ class ReCaptcha(CaptchaService): def _collect_api_info(self): - html = self.plugin.load("http://www.google.com/recaptcha/api.js") + html = self.pyfile.plugin.load("http://www.google.com/recaptcha/api.js") a = re.search(r'po.src = \'(.*?)\';', html).group(1) vers = a.split("/")[5] @@ -102,7 +101,7 @@ class ReCaptcha(CaptchaService): self.log_debug("API language: %s" % language) - html = self.plugin.load("https://apis.google.com/js/api.js") + html = self.pyfile.plugin.load("https://apis.google.com/js/api.js") b = re.search(r'"h":"(.*?)","', html).group(1) jsh = b.decode('unicode-escape') @@ -112,7 +111,7 @@ class ReCaptcha(CaptchaService): def _prepare_time_and_rpc(self): - self.plugin.load("http://www.google.com/recaptcha/api2/demo") + self.pyfile.plugin.load("http://www.google.com/recaptcha/api2/demo") millis = int(round(time.time() * 1000)) @@ -130,7 +129,7 @@ class ReCaptcha(CaptchaService): def _challenge_v2(self, key, parent=None): if parent is None: try: - parent = urlparse.urljoin("http://", urlparse.urlparse(self.plugin.pyfile.url).netloc) + parent = urlparse.urljoin("http://", urlparse.urlparse(self.pyfile.url).netloc) except Exception: parent = "" @@ -139,7 +138,7 @@ class ReCaptcha(CaptchaService): vers, language, jsh = self._collect_api_info() millis, rpc = self._prepare_time_and_rpc() - html = self.plugin.load("https://www.google.com/recaptcha/api2/anchor", + html = self.pyfile.plugin.load("https://www.google.com/recaptcha/api2/anchor", get={'k' : key, 'hl' : language, 'v' : vers, @@ -152,7 +151,7 @@ class ReCaptcha(CaptchaService): token1 = re.search(r'id="recaptcha-token" value="(.*?)">', html) self.log_debug("Token #1: %s" % token1.group(1)) - html = self.plugin.load("https://www.google.com/recaptcha/api2/frame", + html = self.pyfile.plugin.load("https://www.google.com/recaptcha/api2/frame", get={'c' : token1.group(1), 'hl' : language, 'v' : vers, @@ -174,14 +173,14 @@ class ReCaptcha(CaptchaService): cookies=True, ocr=False, timeout=30) - response = b64encode('{"response":"%s"}' % captcha_response) + response = base64.b64encode('{"response":"%s"}' % captcha_response) self.log_debug("Result: %s" % response) timeToSolve = int(round(time.time() * 1000)) - millis_captcha_loading timeToSolveMore = timeToSolve + int(float("0." + str(random.randint(1, 99999999))) * 500) - html = self.plugin.load("https://www.google.com/recaptcha/api2/userverify", + html = self.pyfile.plugin.load("https://www.google.com/recaptcha/api2/userverify", post={'k' : key, 'c' : token3.group(1), 'response': response, diff --git a/module/plugins/captcha/ShareonlineBiz.py b/module/plugins/captcha/ShareonlineBiz.py index da36fa910..3e04bdcad 100644 --- a/module/plugins/captcha/ShareonlineBiz.py +++ b/module/plugins/captcha/ShareonlineBiz.py @@ -6,7 +6,7 @@ from module.plugins.internal.OCR import OCR class ShareonlineBiz(OCR): __name__ = "ShareonlineBiz" __type__ = "ocr" - __version__ = "0.15" + __version__ = "0.16" __status__ = "testing" __description__ = """Shareonline.biz ocr plugin""" diff --git a/module/plugins/captcha/SolveMedia.py b/module/plugins/captcha/SolveMedia.py index 7acb7d85d..f5fb28fa0 100644 --- a/module/plugins/captcha/SolveMedia.py +++ b/module/plugins/captcha/SolveMedia.py @@ -9,7 +9,7 @@ from module.plugins.internal.CaptchaService import CaptchaService class SolveMedia(CaptchaService): __name__ = "SolveMedia" __type__ = "captcha" - __version__ = "0.16" + __version__ = "0.17" __status__ = "testing" __description__ = """SolveMedia captcha service plugin""" @@ -36,7 +36,7 @@ class SolveMedia(CaptchaService): def challenge(self, key=None, data=None): key = key or self.retrieve_key(data) - html = self.plugin.load("http://api.solvemedia.com/papi/challenge.noscript", + html = self.pyfile.plugin.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}) for i in xrange(1, 11): @@ -62,10 +62,10 @@ class SolveMedia(CaptchaService): except Fail, e: self.log_warning(e, trace=True) - self.plugin.invalidCaptcha() + self.pyfile.plugin.invalidCaptcha() result = None - html = self.plugin.load("http://api.solvemedia.com/papi/verify.noscript", + html = self.pyfile.plugin.load("http://api.solvemedia.com/papi/verify.noscript", post={'adcopy_response' : result, 'k' : key, 'l' : "en", @@ -73,7 +73,7 @@ class SolveMedia(CaptchaService): 's' : "standard", 'magic' : magic, 'adcopy_challenge': challenge, - 'ref' : self.plugin.pyfile.url}) + 'ref' : self.pyfile.url}) try: redirect = re.search(r'URL=(.+?)">', html).group(1) @@ -84,7 +84,7 @@ class SolveMedia(CaptchaService): if "error" in html: self.log_warning(_("Captcha code was invalid")) self.log_debug("Retry #%d" % i) - html = self.plugin.load(redirect) + html = self.pyfile.plugin.load(redirect) else: break |