diff options
author | kingzero <devnull@localhost> | 2009-06-16 17:13:21 +0200 |
---|---|---|
committer | kingzero <devnull@localhost> | 2009-06-16 17:13:21 +0200 |
commit | 9dcb55174a2759266704364aaa48f3bcda065de8 (patch) | |
tree | 1f5e2509a3655795043950cff88633784bd21d71 | |
parent | new file list class (diff) | |
download | pyload-9dcb55174a2759266704364aaa48f3bcda065de8.tar.xz |
added captcha support for gigasize.com, see #6
-rw-r--r-- | Plugins/StealthTo.py | 1 | ||||
-rw-r--r-- | captcha/__init__.py | 0 | ||||
-rw-r--r-- | captcha/captcha.py | 25 | ||||
-rw-r--r-- | captcha/gigasize-com.py | 14 | ||||
-rw-r--r-- | module/file_list.py | 2 | ||||
-rwxr-xr-x | pyLoadGui.py | 7 |
6 files changed, 45 insertions, 4 deletions
diff --git a/Plugins/StealthTo.py b/Plugins/StealthTo.py index 40d44b159..6d59f4b44 100644 --- a/Plugins/StealthTo.py +++ b/Plugins/StealthTo.py @@ -44,6 +44,5 @@ class StealthTo(Plugin): self.req.load(url + "/web", post={"authenticity_token": ats[i], "id": str(ids[i]), "link": ("download_" + str(ids[i]))}, cookies=True) new_html = self.req.load(url + "/web", post={"authenticity_token": ats[i], "id": str(ids[i]), "link": "1"}, cookies=True) temp_links.append(re.search(r"iframe src=\"(.*)\" frameborder", new_html).group(1)) - print temp_links self.links = temp_links diff --git a/captcha/__init__.py b/captcha/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/captcha/__init__.py diff --git a/captcha/captcha.py b/captcha/captcha.py new file mode 100644 index 000000000..b57fa1b7e --- /dev/null +++ b/captcha/captcha.py @@ -0,0 +1,25 @@ +import Image +import ImageOps +import subprocess + +class Ocr(object): + def __init__(self, image): + self.image = Image.open(image) + self.image_name = 'captcha_clean.png' + self.result_captcha = '' + + + def threshold(self, value): + self.image = self.image.point(lambda a: a * value +10) + + def run_gocr(self): + self.image.save(self.image_name) + cmd = ['gocr', self.image_name] + self.result_captcha = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].replace('\n','') + + def get_captcha(self): + pass + +if __name__ == '__main__': + ocr = Ocr('gigasize-com/7.jpg') + print ocr.get_captcha() diff --git a/captcha/gigasize-com.py b/captcha/gigasize-com.py new file mode 100644 index 000000000..b48e20da4 --- /dev/null +++ b/captcha/gigasize-com.py @@ -0,0 +1,14 @@ +from captcha import Ocr + +class Gigasize(Ocr): + def __init__(self, image): + Ocr.__init__(self, image) + + def get_captcha(self): + self.threshold(2.8) + self.run_gocr() + return self.result_captcha + +if __name__ == '__main__': + ocr = Gigasize('gigasize-com/7.jpg') + print ocr.get_captcha() diff --git a/module/file_list.py b/module/file_list.py index 932fb0b13..e8cc49ab2 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -32,7 +32,7 @@ class File_List(object): def set_core(self, core): self.core = core - def new_pyfile(self) + def new_pyfile(self): pyfile = PyLoadFile(self, url) pyfile.download_folder = self.core.config['download_folder'] pyfile.id = self.id diff --git a/pyLoadGui.py b/pyLoadGui.py index 4e17da403..0f256686f 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -25,6 +25,7 @@ import socket from time import sleep from threading import Thread from pyLoadCore import Core +import subprocess import wxversion wxversion.select('2.8') @@ -133,8 +134,10 @@ class Pyload_Main_Gui(wx.Frame): try: self.thread = SocketThread(socket_host.host.GetValue(), int(socket_host.port.GetValue()), socket_host.password.GetValue(), self) except socket.error: - self.core = _Core_Thread() - self.core.start() + #self.core = _Core_Thread() + #self.core.start() + cmd = ['python', 'pyLoadCore.py'] + subprocess.call(cmd) sleep(1) self.thread = SocketThread(socket_host.host.GetValue(), int(socket_host.port.GetValue()), socket_host.password.GetValue(), self) |