From c1764e2fea0bb05164c83a876e8cd58b97f58f25 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Jun 2015 17:31:38 +0200 Subject: Update all --- module/plugins/internal/AdYouLike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/AdYouLike.py') diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py index a9c194dda..b7324ef8e 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/internal/AdYouLike.py @@ -41,7 +41,7 @@ class AdYouLike(Captcha): # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} ayl = json_loads(ayl) - html = self.plugin.req.load("http://api-ayl.appspot.com/challenge", + html = self.plugin.load("http://api-ayl.appspot.com/challenge", get={'key' : ayl['adyoulike']['key'], 'env' : ayl['all']['env'], 'callback': callback}) -- cgit v1.2.3 From 20b6a2ec022202b0efb6cb69415239fb8f4d1445 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 18:59:20 +0200 Subject: Spare code cosmetics (2) --- module/plugins/internal/AdYouLike.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'module/plugins/internal/AdYouLike.py') diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py index b7324ef8e..f623ed268 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/internal/AdYouLike.py @@ -37,8 +37,8 @@ class AdYouLike(Captcha): def challenge(self, key=None, html=None): ayl, callback = key or self.retrieve_key(html) - # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, - # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} + #: {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, + #: "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", @@ -57,15 +57,15 @@ class AdYouLike(Captcha): def result(self, server, challenge): - # Adyoulike.g._jsonp_5579316662423138 - # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, - # "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], - # "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", - # "iframes":{"big":""},"shares":{},"id":256, - # "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, - # "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, - # "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) + #: Adyoulike.g._jsonp_5579316662423138 + #: ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, + #: "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], + #: "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", + #: "iframes":{"big":""},"shares":{},"id":256, + #: "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, + #: "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, + #: "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) if isinstance(server, basestring): server = json_loads(server) -- cgit v1.2.3 From b1759bc440cd6013837697eb8de540914f693ffd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Jul 2015 01:23:55 +0200 Subject: No camelCase style anymore --- module/plugins/internal/AdYouLike.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal/AdYouLike.py') diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py index f623ed268..07e7e4d17 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/internal/AdYouLike.py @@ -9,7 +9,7 @@ from module.plugins.internal.Captcha import Captcha class AdYouLike(Captcha): __name__ = "AdYouLike" __type__ = "captcha" - __version__ = "0.06" + __version__ = "0.07" __description__ = """AdYouLike captcha service plugin""" __license__ = "GPLv3" @@ -27,10 +27,10 @@ class AdYouLike(Captcha): n = re.search(self.CALLBACK_PATTERN, html) if m and n: self.key = (m.group(1).strip(), n.group(1).strip()) - self.logDebug("Ayl: %s | Callback: %s" % self.key) + self.log_debug("Ayl: %s | Callback: %s" % self.key) return self.key #: key is the tuple(ayl, callback) else: - self.logWarning("Ayl or callback pattern not found") + self.log_warning("Ayl or callback pattern not found") return None @@ -51,7 +51,7 @@ class AdYouLike(Captcha): except AttributeError: self.fail(_("AdYouLike challenge pattern not found")) - self.logDebug("Challenge: %s" % challenge) + self.log_debug("Challenge: %s" % challenge) return self.result(ayl, challenge), challenge @@ -86,6 +86,6 @@ class AdYouLike(Captcha): '_ayl_token_challenge': challenge['token'], '_ayl_response' : response} - self.logDebug("Result: %s" % result) + self.log_debug("Result: %s" % result) return result -- cgit v1.2.3 From 9e5d813d7721e351ac02ba72bdc473a7d77ba6b7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Jul 2015 20:04:36 +0200 Subject: Code cosmetics --- module/plugins/internal/AdYouLike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/AdYouLike.py') diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py index 07e7e4d17..9036b4632 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/internal/AdYouLike.py @@ -30,7 +30,7 @@ class AdYouLike(Captcha): self.log_debug("Ayl: %s | Callback: %s" % self.key) return self.key #: key is the tuple(ayl, callback) else: - self.log_warning("Ayl or callback pattern not found") + self.log_warning(_("Ayl or callback pattern not found")) return None -- cgit v1.2.3 From dad722ac7255640e7e0541c4094a4d2e4de79cd3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 00:05:58 +0200 Subject: Code cosmetics (2) --- module/plugins/internal/AdYouLike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/AdYouLike.py') diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py index 9036b4632..64ce6e7fa 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/internal/AdYouLike.py @@ -28,7 +28,7 @@ class AdYouLike(Captcha): if m and n: self.key = (m.group(1).strip(), n.group(1).strip()) self.log_debug("Ayl: %s | Callback: %s" % self.key) - return self.key #: key is the tuple(ayl, callback) + return self.key #: Key is the tuple(ayl, callback) else: self.log_warning(_("Ayl or callback pattern not found")) return None -- cgit v1.2.3 From ff9383bfe06d14d23bc0ed6af79aa8967965d078 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 10:59:52 +0200 Subject: Code cosmetics (3) --- module/plugins/internal/AdYouLike.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'module/plugins/internal/AdYouLike.py') diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py index 64ce6e7fa..10f281494 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/internal/AdYouLike.py @@ -37,8 +37,8 @@ class AdYouLike(Captcha): def challenge(self, key=None, html=None): ayl, callback = key or self.retrieve_key(html) - #: {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, - #: "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} + #: {'adyoulike':{'key':"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, + #: '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", @@ -58,14 +58,14 @@ class AdYouLike(Captcha): def result(self, server, challenge): #: Adyoulike.g._jsonp_5579316662423138 - #: ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, - #: "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], - #: "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", - #: "iframes":{"big":""},"shares":{},"id":256, - #: "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, - #: "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, - #: "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) + #: ({'translations':{'fr':{'instructions_visual':"Recopiez « Soonnight » ci-dessous :"}}, + #: 'site_under':true,'clickable':true,'pixels':{'VIDEO_050':[],'DISPLAY':[],'VIDEO_000':[],'VIDEO_100':[], + #: 'VIDEO_025':[],'VIDEO_075':[]},'medium_type':"image/adyoulike", + #: 'iframes':{'big':""},'shares':{},'id':256, + #: 'token':"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1",'formats':{'small':{'y':300,'x':0,'w':300,'h':60}, + #: 'big':{'y':0,'x':0,'w':300,'h':250},'hover':{'y':440,'x':0,'w':300,'h':60}}, + #: 'tid':"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) if isinstance(server, basestring): server = json_loads(server) -- cgit v1.2.3 From d38e830b7c0b3c6561a0072c74bbccb5fcdf4a61 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 14:43:42 +0200 Subject: New __status__ magic key --- module/plugins/internal/AdYouLike.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/internal/AdYouLike.py') diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py index 10f281494..fcb9b8372 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/internal/AdYouLike.py @@ -10,6 +10,7 @@ class AdYouLike(Captcha): __name__ = "AdYouLike" __type__ = "captcha" __version__ = "0.07" + __status__ = "stable" __description__ = """AdYouLike captcha service plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 027cb529d79558de19c47da88a782b31745a65c9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 21 Jul 2015 22:53:37 +0200 Subject: New Captcha skeleton --- module/plugins/internal/AdYouLike.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal/AdYouLike.py') diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py index fcb9b8372..d14babb51 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/internal/AdYouLike.py @@ -3,10 +3,10 @@ import re from module.common.json_layer import json_loads -from module.plugins.internal.Captcha import Captcha +from module.plugins.internal.CaptchaService import CaptchaService -class AdYouLike(Captcha): +class AdYouLike(CaptchaService): __name__ = "AdYouLike" __type__ = "captcha" __version__ = "0.07" @@ -21,8 +21,8 @@ class AdYouLike(Captcha): CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' - def detect_key(self, html=None): - html = html or self.retrieve_html() + def detect_key(self, data=None): + html = data or self.retrieve_data() m = re.search(self.AYL_PATTERN, html) n = re.search(self.CALLBACK_PATTERN, html) @@ -35,8 +35,8 @@ class AdYouLike(Captcha): return None - def challenge(self, key=None, html=None): - ayl, callback = key or self.retrieve_key(html) + def challenge(self, key=None, data=None): + ayl, callback = key or self.retrieve_key(data) #: {'adyoulike':{'key':"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, #: 'all':{'element_id':"ayl_private_cap_92300",'lang':"fr",'env':"prod"}} -- cgit v1.2.3 From 6af9b38a8d5d49355b85aef6ddd003605d6bba05 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 23 Jul 2015 23:44:45 +0200 Subject: Improve Captcha --- module/plugins/internal/AdYouLike.py | 92 ------------------------------------ 1 file changed, 92 deletions(-) delete mode 100644 module/plugins/internal/AdYouLike.py (limited to 'module/plugins/internal/AdYouLike.py') diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py deleted file mode 100644 index d14babb51..000000000 --- a/module/plugins/internal/AdYouLike.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.common.json_layer import json_loads -from module.plugins.internal.CaptchaService import CaptchaService - - -class AdYouLike(CaptchaService): - __name__ = "AdYouLike" - __type__ = "captcha" - __version__ = "0.07" - __status__ = "stable" - - __description__ = """AdYouLike captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - AYL_PATTERN = r'Adyoulike\.create\s*\((.+?)\)' - CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' - - - def detect_key(self, data=None): - html = data or self.retrieve_data() - - m = re.search(self.AYL_PATTERN, html) - n = re.search(self.CALLBACK_PATTERN, html) - if m and n: - self.key = (m.group(1).strip(), n.group(1).strip()) - self.log_debug("Ayl: %s | Callback: %s" % self.key) - return self.key #: Key is the tuple(ayl, callback) - else: - self.log_warning(_("Ayl or callback pattern not found")) - return None - - - def challenge(self, key=None, data=None): - ayl, callback = key or self.retrieve_key(data) - - #: {'adyoulike':{'key':"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, - #: '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", - get={'key' : ayl['adyoulike']['key'], - 'env' : ayl['all']['env'], - 'callback': callback}) - try: - challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) - - except AttributeError: - self.fail(_("AdYouLike challenge pattern not found")) - - self.log_debug("Challenge: %s" % challenge) - - return self.result(ayl, challenge), challenge - - - def result(self, server, challenge): - #: Adyoulike.g._jsonp_5579316662423138 - #: ({'translations':{'fr':{'instructions_visual':"Recopiez « Soonnight » ci-dessous :"}}, - #: 'site_under':true,'clickable':true,'pixels':{'VIDEO_050':[],'DISPLAY':[],'VIDEO_000':[],'VIDEO_100':[], - #: 'VIDEO_025':[],'VIDEO_075':[]},'medium_type':"image/adyoulike", - #: 'iframes':{'big':""},'shares':{},'id':256, - #: 'token':"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1",'formats':{'small':{'y':300,'x':0,'w':300,'h':60}, - #: 'big':{'y':0,'x':0,'w':300,'h':250},'hover':{'y':440,'x':0,'w':300,'h':60}}, - #: 'tid':"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) - - if isinstance(server, basestring): - server = json_loads(server) - - if isinstance(challenge, basestring): - challenge = json_loads(challenge) - - try: - instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual'] - result = re.search(u'«(.+?)»', instructions_visual).group(1).strip() - - except AttributeError: - self.fail(_("AdYouLike result not found")) - - result = {'_ayl_captcha_engine' : "adyoulike", - '_ayl_env' : server['all']['env'], - '_ayl_tid' : challenge['tid'], - '_ayl_token_challenge': challenge['token'], - '_ayl_response' : response} - - self.log_debug("Result: %s" % result) - - return result -- cgit v1.2.3