diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-10-19 04:48:07 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-10-19 04:48:07 +0200 |
commit | ffd38f027ed103f7b39ec78c6af0d182774950a4 (patch) | |
tree | e6d88b064a38bb44932674f32ac602efc786468b /module/plugins/internal | |
parent | Merge pull request #2054 from GammaC0de/patch-1 (diff) | |
download | pyload-ffd38f027ed103f7b39ec78c6af0d182774950a4.tar.xz |
Spare fixes
Diffstat (limited to 'module/plugins/internal')
-rw-r--r-- | module/plugins/internal/Captcha.py | 2 | ||||
-rw-r--r-- | module/plugins/internal/Container.py | 2 | ||||
-rw-r--r-- | module/plugins/internal/Extractor.py | 6 | ||||
-rw-r--r-- | module/plugins/internal/Hoster.py | 27 | ||||
-rw-r--r-- | module/plugins/internal/SimpleCrypter.py | 15 | ||||
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 17 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 4 | ||||
-rw-r--r-- | module/plugins/internal/XFSHoster.py | 2 |
8 files changed, 41 insertions, 34 deletions
diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py index 5993f0771..e0518f67b 100644 --- a/module/plugins/internal/Captcha.py +++ b/module/plugins/internal/Captcha.py @@ -112,7 +112,7 @@ class Captcha(Plugin): os.remove(tmp_img.name) except OSError, e: - self.log_warning(_("Error removing: %s") % tmp_img.name, e) + self.log_warning(_("Error removing `%s`") % tmp_img.name, e) #self.log_info(_("Captcha result: ") + result) #@TODO: Remove from here? diff --git a/module/plugins/internal/Container.py b/module/plugins/internal/Container.py index 946953db5..ba8b96f3b 100644 --- a/module/plugins/internal/Container.py +++ b/module/plugins/internal/Container.py @@ -78,4 +78,4 @@ class Container(Crypter): try: os.remove(self.pyfile.url) except OSError, e: - self.log_warning(_("Error removing: %s") % self.pyfile.url, e) + self.log_warning(_("Error removing `%s`") % self.pyfile.url, e) diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 6629b0652..a8002a1d2 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -50,7 +50,7 @@ class Extractor(Plugin): @classmethod - def is_archive(cls, filename): + def isarchive(cls, filename): name = os.path.basename(filename).lower() return any(name.endswith(ext) for ext in cls.EXTENSIONS) @@ -74,8 +74,8 @@ class Extractor(Plugin): processed = [] for fname, id, fout in files_ids: - if cls.is_archive(fname): - pname = re.sub(cls.re_multipart, "", fname) if cls.is_multipart(fname) else os.path.splitext(fname)[0] + if cls.isarchive(fname): + pname = re.sub(cls.re_multipart, "", fname) if cls.ismultipart(fname) else os.path.splitext(fname)[0] if pname not in processed: processed.append(pname) targets.append((fname, id, fout)) diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py index f042fb257..13d7afad8 100644 --- a/module/plugins/internal/Hoster.py +++ b/module/plugins/internal/Hoster.py @@ -5,7 +5,6 @@ from __future__ import with_statement import os import re -from module.network.HTTPRequest import BadHeader from module.plugins.internal.Base import Base, create_getInfo, parse_fileInfo from module.plugins.internal.Plugin import Fail, Retry from module.plugins.internal.utils import encode, exists, fixurl, fs_join, parse_name @@ -14,7 +13,7 @@ from module.plugins.internal.utils import encode, exists, fixurl, fs_join, parse class Hoster(Base): __name__ = "Hoster" __type__ = "hoster" - __version__ = "0.38" + __version__ = "0.39" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -102,7 +101,7 @@ class Hoster(Base): raise Fail(e) - def is_download(self, url, resume=None, redirect=True): + def isdownload(self, url, resume=None, redirect=True): link = False maxredirs = 10 @@ -177,7 +176,7 @@ class Hoster(Base): self.log_debug("DOWNLOAD URL " + url, *["%s=%s" % (key, val) for key, val in locals().items() if key not in ("self", "url", "_[1]")]) - dl_url = self.is_download(url, resume) + dl_url = self.isdownload(url, resume) dl_basename = parse_name(self.pyfile.name) self.pyfile.name = dl_basename @@ -185,6 +184,8 @@ class Hoster(Base): if not dl_url: self.error("Invalid download url") + + self.captcha.correct() if self.pyload.config.get("download", "skip_existing"): @@ -226,14 +227,20 @@ class Hoster(Base): cookies=cookies, chunks=chunks, resume=resume, progressNotify=self.pyfile.setProgress, disposition=disposition) - except BadHeader, e: - if e.code in (404, 410): - self.pyfile.setStatus("offline") - raise BadHeader(e) - finally: self.pyfile.size = self.req.size + if self.req.code in (404, 410): + bad_file = fs_join(dl_dirname, newname) + try: + os.remove(bad_file) + + except OSError, e: + self.log_debug(_("Error removing `%s`") % bad_file, e) + + finally: + return "" + #@TODO: Recheck in 0.4.10 if disposition and newname: safename = parse_name(newname.split(' filename*=')[0]) @@ -333,7 +340,7 @@ class Hoster(Base): os.remove(last_download) except OSError, e: - self.log_warning(_("Error removing: %s") % last_download, e) + self.log_warning(_("Error removing `%s`") % last_download, e) else: self.log_info(_("File deleted: ") + self.last_download) diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 1457c6fe5..231fb8810 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -2,6 +2,7 @@ import re +from module.network.RequestFactory import getURL as get_url from module.plugins.internal.Crypter import Crypter, create_getInfo, parse_fileInfo from module.plugins.internal.utils import replace_patterns, set_cookie, set_cookies @@ -9,7 +10,7 @@ from module.plugins.internal.utils import replace_patterns, set_cookie, set_cook class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.71" + __version__ = "0.72" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -103,15 +104,15 @@ class SimpleCrypter(Crypter): except BadHeader, e: info['error'] = "%d: %s" % (e.code, e.content) - if e.code in (404, 410): - info['status'] = 1 - - elif e.code is 503: - info['status'] = 6 - except Exception: pass + if pyreq.code in (404, 410): + info['status'] = 1 + + elif pyreq.code == 503: + info['status'] = 6 + if html: if cls.OFFLINE_PATTERN and re.search(cls.OFFLINE_PATTERN, html) is not None: info['status'] = 1 diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 8307c6236..8dcabdb6c 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -6,7 +6,6 @@ import os import re import time -from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL as get_url from module.plugins.internal.Hoster import Hoster, create_getInfo, parse_fileInfo from module.plugins.internal.Plugin import Fail @@ -18,7 +17,7 @@ from module.plugins.internal.utils import (encode, fixup, parse_name, parse_size class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.99" + __version__ = "2.00" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -150,15 +149,15 @@ class SimpleHoster(Hoster): except BadHeader, e: info['error'] = "%d: %s" % (e.code, e.content) - if e.code in (404, 410): - info['status'] = 1 - - elif e.code is 503: - info['status'] = 6 - except Exception: pass + if pyreq.code in (404, 410): + info['status'] = 1 + + elif pyreq.code == 503: + info['status'] = 6 + if html: if cls.OFFLINE_PATTERN and re.search(cls.OFFLINE_PATTERN, html) is not None: info['status'] = 1 @@ -428,7 +427,7 @@ class SimpleHoster(Hoster): def handle_direct(self, pyfile): - self.link = self.is_download(pyfile.url) + self.link = self.isdownload(pyfile.url) def handle_multi(self, pyfile): #: Multi-hoster handler diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index c1ecccf40..835c372ab 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -69,7 +69,7 @@ class UnRar(Extractor): @classmethod - def is_multipart(cls, filename): + def ismultipart(cls, filename): return True if cls.re_multipart.search(filename) else False @@ -166,7 +166,7 @@ class UnRar(Extractor): files = [self.filename] #: eventually Multipart Files - files.extend(fs_join(dir, os.path.basename(file)) for file in filter(self.is_multipart, os.listdir(dir)) + files.extend(fs_join(dir, os.path.basename(file)) for file in filter(self.ismultipart, os.listdir(dir)) if re.sub(self.re_multipart, ".rar", name) == re.sub(self.re_multipart, ".rar", file)) return files diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index 30191a7e7..7e6439ecf 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -104,7 +104,7 @@ class XFSHoster(SimpleHoster): def handle_free(self, pyfile): for i in xrange(1, 6): - self.log_debug("Getting download link #%d" % i) + self.log_debug("Getting download link #%d..." % i) self.check_errors() |