From 922d6aca5f0a1a3ce9e6fb855a3e55c367069943 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 10 Aug 2009 20:18:37 +0200 Subject: some plugin fixes --- Plugins/UploadedTo.py | 7 +++++-- captcha/NetloadIn.py | 2 ++ module/network/Request.py | 38 +++++++++++++++++--------------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py index e163a3230..bbfeb7f19 100644 --- a/Plugins/UploadedTo.py +++ b/Plugins/UploadedTo.py @@ -48,6 +48,8 @@ class UploadedTo(Plugin): thread.wait(self.parent) + pyfile.status.filename = self.get_file_name() + tries += 1 if tries > 5: raise Exception, "Error while preparing DL, HTML dump: %s" % self.html @@ -75,13 +77,14 @@ class UploadedTo(Plugin): return None def get_file_name(self): - if not self.want_reconnect: + try: file_name = re.search(r"\s+(.+)\s", self.html).group(1) file_suffix = re.search(r"(\..+)", self.html) if not file_suffix: return file_name return file_name + file_suffix.group(1) - else: + except: + self.parent.status.url = None return self.parent.url def file_exists(self): diff --git a/captcha/NetloadIn.py b/captcha/NetloadIn.py index 9799a6a2b..df8809a6a 100644 --- a/captcha/NetloadIn.py +++ b/captcha/NetloadIn.py @@ -9,7 +9,9 @@ class NetloadIn(OCR): self.to_greyscale() self.clean(3) self.clean(3) + self.logger.debug("Start tesseract") self.run_tesser() + self.logger.debug("Finished tesseract") self.correct({ ("$", "g"): "5", diff --git a/module/network/Request.py b/module/network/Request.py index 8e3ece456..a2bc3ec3d 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -147,27 +147,23 @@ class Request: if not self.dl: self.dl = True file = open(filename, 'wb') - try: - conn = self.downloader.open(req, post) - if conn.headers.has_key("content-length"): - self.dl_size = int(conn.headers["content-length"]) - else: - self.dl_size = 0 - self.dl_arrived = 0 - self.dl_time = time.time() - for chunk in conn: - if self.abort: raise AbortDownload - self.dl_arrived += len(chunk) - file.write(chunk) - - file.close() - self.dl = False - self.dl_finished = time.time() - return True - except HTTPError, e: - print e - except URLError, e: - print e + + conn = self.downloader.open(req, post) + if conn.headers.has_key("content-length"): + self.dl_size = int(conn.headers["content-length"]) + else: + self.dl_size = 0 + self.dl_arrived = 0 + self.dl_time = time.time() + for chunk in conn: + if self.abort: raise AbortDownload + self.dl_arrived += len(chunk) + file.write(chunk) + + file.close() + self.dl = False + self.dl_finished = time.time() + return True def get_speed(self): try: -- cgit v1.2.3