summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2016-03-07 00:20:32 +0100
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2016-03-07 00:20:32 +0100
commite4fc68fee71f2bfee57932a04800406f44bdbf16 (patch)
treeda5e925ffa86b1a8cff22badcc28a4ab3064ec48
parent[IRC] Update (diff)
parentAdded sound captcha options (diff)
downloadpyload-e4fc68fee71f2bfee57932a04800406f44bdbf16.tar.xz
Merge pull request #2375 from sodd/adecaptcha
[UlozTo] Added support for audio Captcha recognition
-rw-r--r--module/plugins/captcha/UlozTo.py26
-rw-r--r--module/plugins/hoster/UlozTo.py10
2 files changed, 34 insertions, 2 deletions
diff --git a/module/plugins/captcha/UlozTo.py b/module/plugins/captcha/UlozTo.py
new file mode 100644
index 000000000..7e7297138
--- /dev/null
+++ b/module/plugins/captcha/UlozTo.py
@@ -0,0 +1,26 @@
+try:
+ import adecaptcha.clslib as clslib
+ adecaptcha_available = True
+except ImportError:
+ adecaptcha_available = False
+
+import os.path
+
+
+
+class UlozTo(object):
+ __name__ = "UlozTo"
+ def __init__(self, plugin=None):
+ pass
+ self._plugin=plugin
+
+
+ def recognize(self, audio):
+ """ Audio decoding - more info could be found at https://launchpad.net/adecaptcha """
+ #print "!!!CAPTCHA :", audio
+ if adecaptcha_available:
+ cfg_file=os.path.join(os.path.split(clslib.__file__)[0], 'ulozto.cfg')
+ text= clslib.classify_audio_file(audio, cfg_file)
+ return text
+ else:
+ pass
diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py
index 1e9c2813d..12fe83c47 100644
--- a/module/plugins/hoster/UlozTo.py
+++ b/module/plugins/hoster/UlozTo.py
@@ -15,7 +15,7 @@ def convert_decimal_prefix(m):
class UlozTo(SimpleHoster):
__name__ = "UlozTo"
__type__ = "hoster"
- __version__ = "1.19"
+ __version__ = "1.20"
__status__ = "testing"
__pattern__ = r'http://(?:www\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj\.cz|zachowajto\.pl)/(?:live/)?(?P<ID>\w+/[^/?]*)'
@@ -23,6 +23,7 @@ class UlozTo(SimpleHoster):
("use_premium" , "bool", "Use premium account if available" , True),
("fallback" , "bool", "Fallback to free download if premium fails" , True),
("chk_filesize", "bool", "Check file size" , True),
+ ("captcha" , "Image;Sound", "Captcha recognition" , "Image"),
("max_wait" , "int" , "Reconnect if waiting time is greater than minutes", 10 )]
__description__ = """Uloz.to hoster plugin"""
@@ -78,6 +79,10 @@ class UlozTo(SimpleHoster):
self.log_debug("xapca: %s" % xapca)
data = json.loads(xapca)
+ if self.config.get("captcha") == "Image":
+ captcha_value = self.captcha.decrypt(data['image'])
+ else:
+ captcha_value = self.captcha.decrypt(str(data['sound']), input_type='wav', ocr="UlozTo")
captcha_value = self.captcha.decrypt(data['image'])
self.log_debug("CAPTCHA HASH: " + data['hash'], "CAPTCHA SALT: %s" % data['salt'], "CAPTCHA VALUE: " + captcha_value)
@@ -135,7 +140,8 @@ class UlozTo(SimpleHoster):
})
if check == "wrong_captcha":
- self.retry_captcha()
+ self.captcha.invalid()
+ self.retry(msg=_("Wrong captcha code"))
elif check == "offline":
self.offline()