summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/plugins/captcha/captcha.py17
-rwxr-xr-xpyLoadCore.py27
2 files changed, 34 insertions, 10 deletions
diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py
index 60b81a2cf..27c362f17 100644
--- a/module/plugins/captcha/captcha.py
+++ b/module/plugins/captcha/captcha.py
@@ -24,7 +24,6 @@ from os.path import abspath
import logging
import subprocess
#import tempfile
-import threading
import Image
import TiffImagePlugin
@@ -32,7 +31,6 @@ import PngImagePlugin
import GifImagePlugin
import JpegImagePlugin
-from module.web.ServerThread import Output
class OCR(object):
@@ -53,7 +51,7 @@ class OCR(object):
def threshold(self, value):
self.image = self.image.point(lambda a: a * value + 10)
- def run(self, command, inputdata=None):
+ def run(self, command):
"""Run a command"""
popen = subprocess.Popen(command, bufsize = -1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -101,8 +99,11 @@ class OCR(object):
self.run(tessparams)
self.logger.debug("read txt")
- with open(tmpTxt.name, 'r') as f:
- self.result_captcha = f.read().replace("\n", "")
+ try:
+ with open(tmpTxt.name, 'r') as f:
+ self.result_captcha = f.read().replace("\n", "")
+ except:
+ self.result_captcha = ""
self.logger.debug(self.result_captcha)
@@ -254,7 +255,7 @@ class OCR(object):
black_pixel_in_col = False
for y in xrange(height):
if pixels[x, y] != 255:
- if started == False:
+ if not started:
started = True
firstX = x
lastX = x
@@ -304,9 +305,7 @@ if __name__ == '__main__':
ocr.load_image("B.jpg")
ocr.to_greyscale()
ocr.eval_black_white(140)
- ocr.derotate_by_avergage()
- ocr.run_gocr()
- print "GOCR", ocr.result_captcha
+ ocr.derotate_by_average()
ocr.run_tesser()
print "Tesseract", ocr.result_captcha
ocr.image.save("derotated.jpg")
diff --git a/pyLoadCore.py b/pyLoadCore.py
index ad4b0cc90..dd0c1f20f 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -200,6 +200,7 @@ class Core(object):
#self.check_install("tesseract", _("tesseract for captcha reading"), False)
self.check_file(self.config['general']['download_folder'], _("folder for downloads"), True)
+ self.check_file("links.txt", _("file for links"))
if self.config['ssl']['activated']:
self.check_install("OpenSSL", _("OpenSSL for secure connection"), True)
@@ -243,7 +244,31 @@ class Core(object):
self.hookManager.coreReady()
self.config.save() #save so config files gets filled
-
+
+ link_file = join(pypath, "links.txt")
+
+ if exists(link_file):
+ f = open(link_file, "rb")
+ links = [x.strip() for x in f.readlines() if x.strip()]
+ if links:
+ self.server_methods.add_package("links.txt", links)
+ f.close()
+ try:
+ f = open(link_file, "wb")
+ f.close()
+ except:
+ pass
+
+ link_file = "links.txt"
+ if exists(link_file):
+ f = open(link_file, "rb")
+ links = [x.strip() for x in f.readlines() if x.strip()]
+ if links:
+ self.server_methods.add_package("links.txt", links)
+ f.close()
+ f = open(link_file, "wb")
+ f.close()
+
while True:
sleep(2)