diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2016-06-17 05:50:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-17 05:50:38 +0200 |
commit | 8f3bc7699d27784dc75fdaa43150a7a70722aea8 (patch) | |
tree | f4f0a7a7173b254e56fa0fc57ab2a0c48b566e9e /module | |
parent | [UptoboxCom] fix #2506 (diff) | |
parent | UnRar FIX file exclusion not working (diff) | |
download | pyload-8f3bc7699d27784dc75fdaa43150a7a70722aea8.tar.xz |
ExtractArchive Fix/#2168
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 29 | ||||
-rw-r--r-- | module/plugins/internal/Extractor.py | 15 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 11 | ||||
-rw-r--r-- | module/plugins/internal/UnTar.py | 14 | ||||
-rw-r--r-- | module/plugins/internal/UnZip.py | 7 |
5 files changed, 44 insertions, 32 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 6d559bfcb..fed9a62b9 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -98,8 +98,8 @@ class ArchiveQueue(object): class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.57" - __status__ = "broken" + __version__ = "1.58" + __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -277,15 +277,15 @@ class ExtractArchive(Addon): matched = False success = True - files_ids = dict((fdata['name'], ((fsjoin(dl_folder, pypack.folder, fdata['name'])), fid, out)) for fid, fdata \ - in sorted(pypack.getChildren().values(), key=lambda k: k['name'])).items() #: Remove duplicates + files_ids = dict((fdata['name'], (fdata['id'], (fsjoin(dl_folder, pypack.folder, fdata['name'])), out)) for fdata \ + in pypack.getChildren().values()).values() #: Remove duplicates #: Check as long there are unseen files while files_ids: new_files_ids = [] if extensions: - files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ + files_ids = [(fid, fname, fout) for fid, fname, fout in files_ids \ if filter(lambda ext: fname.lower().endswith(ext), extensions)] for Extractor in self.extractors: @@ -294,7 +294,7 @@ class ExtractArchive(Addon): self.log_debug("Targets for %s: %s" % (Extractor.__name__, targets)) matched = True - for fname, fid, fout in targets: + for fid, fname, fout in targets: name = os.path.basename(fname) if not exists(fname): @@ -304,15 +304,14 @@ class ExtractArchive(Addon): self.log_info(name, _("Extract to: %s") % fout) try: pyfile = self.pyload.files.getFile(fid) - archive = Extractor(self, + archive = Extractor(pyfile, fname, fout, fullpath, overwrite, excludefiles, priority, - keepbroken, - fid) + keepbroken) thread.addActive(pyfile) archive.init() @@ -330,12 +329,12 @@ class ExtractArchive(Addon): continue #: Remove processed file and related multiparts from list - files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ - if fname not in archive.items()] + files_ids = [(fid, fname, fout) for fid, fname, fout in files_ids \ + if fname not in archive.chunks()] self.log_debug("Extracted files: %s" % new_files) - for file in new_files: - self.set_permissions(file) + for filename in new_files: + self.set_permissions(filename) for filename in new_files: file = encode(fsjoin(os.path.dirname(archive.filename), filename)) @@ -344,7 +343,7 @@ class ExtractArchive(Addon): continue if recursive and os.path.isfile(file): - new_files_ids.append((filename, fid, os.path.dirname(filename))) #: Append as new target + new_files_ids.append((fid, filename, os.path.dirname(filename))) #: Append as new target self.manager.dispatchEvent("archive_extracted", pyfile, archive) @@ -447,7 +446,7 @@ class ExtractArchive(Addon): pyfile.setProgress(100) pyfile.setStatus("processing") - delfiles = archive.items() + delfiles = archive.chunks() self.log_debug("Would delete: " + ", ".join(delfiles)) if self.config.get('delete'): diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 8a16cdd38..a912843a1 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -23,7 +23,7 @@ class PasswordError(Exception): class Extractor(Plugin): __name__ = "Extractor" __type__ = "extractor" - __version__ = "0.42" + __version__ = "0.43" __status__ = "stable" __description__ = """Base extractor plugin""" @@ -104,7 +104,7 @@ class Extractor(Plugin): self.excludefiles = excludefiles self.priority = priority self.keepbroken = keepbroken - self.progress = lambda x: pyfile.setProgress(int(x)) + self.files = None self.init() @@ -119,11 +119,6 @@ class Extractor(Plugin): return encode(self.out) - def _log(self, level, plugintype, pluginname, messages): - messages = (self.__name__,) + messages - return self.pyfile.plugin._log(level, plugintype, self.pyfile.plugin.__name__, messages) - - def verify(self, password=None): """ Testing with Extractors built-in method @@ -156,3 +151,9 @@ class Extractor(Plugin): Return list of archive files """ raise NotImplementedError + + def progress(self, x): + """ + Set extraction progress + """ + return self.pyfile.setProgress(int(x)) diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 3b1d7b290..18416a4fe 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -12,7 +12,7 @@ from module.plugins.internal.misc import decode, encode, fsjoin, renice class UnRar(Extractor): __name__ = "UnRar" __type__ = "extractor" - __version__ = "1.31" + __version__ = "1.32" __status__ = "testing" __description__ = """RAR extractor plugin""" @@ -123,7 +123,7 @@ class UnRar(Extractor): break #: Reading a percentage sign -> set progress and restart if c == "%": - self.notifyprogress(int(s)) + self.pyfile.setProgress(int(s)) s = "" #: Not reading a digit -> therefore restart elif c not in string.digits: @@ -155,6 +155,8 @@ class UnRar(Extractor): if p.returncode: raise ArchiveError(_("Process return code: %d") % p.returncode) + return self.list(password) + def chunks(self): dir, name = os.path.split(self.filename) @@ -192,7 +194,8 @@ class UnRar(Extractor): for f in decode(out).splitlines(): result.add(fsjoin(self.dest, f.strip())) - return list(result) + self.files = list(result) + return self.files def call_cmd(self, command, *xargs, **kwargs): @@ -206,7 +209,7 @@ class UnRar(Extractor): args.append("-or") for word in self.excludefiles: - args.append("-x'%s'" % word.strip()) + args.append("-x%s" % word.strip()) #: Assume yes on all queries args.append("-y") diff --git a/module/plugins/internal/UnTar.py b/module/plugins/internal/UnTar.py index f2a140ca7..13a233634 100644 --- a/module/plugins/internal/UnTar.py +++ b/module/plugins/internal/UnTar.py @@ -12,7 +12,7 @@ from module.plugins.internal.misc import encode class UnTar(Extractor): __name__ = "UnTar" __type__ = "extractor" - __version__ = "0.01" + __version__ = "0.02" __status__ = "stable" __description__ = """TAR extractor plugin""" @@ -25,7 +25,10 @@ class UnTar(Extractor): @classmethod def isarchive(cls, filename): - return tarfile.is_tarfile(encode(filename)) + try: + return tarfile.is_tarfile(encode(filename)) + except: + return False @classmethod @@ -35,7 +38,8 @@ class UnTar(Extractor): def list(self, password=None): with tarfile.open(self.target) as t: - return t.getnames() + self.files = t.getnames() + return self.files def verify(self, password=None): @@ -53,11 +57,13 @@ class UnTar(Extractor): def extract(self, password=None): - self.verify() + self.verify(password) try: with tarfile.open(self.target, errorlevel=2) as t: t.extractall(self.dest) + self.files = t.getnames() + return self.files except tarfile.ExtractError, e: self.log_warning(e) diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index 50ab80da3..4a05ea155 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -12,7 +12,7 @@ from module.plugins.internal.misc import encode class UnZip(Extractor): __name__ = "UnZip" __type__ = "extractor" - __version__ = "1.21" + __version__ = "1.22" __status__ = "stable" __description__ = """ZIP extractor plugin""" @@ -36,7 +36,8 @@ class UnZip(Extractor): def list(self, password=None): with zipfile.ZipFile(self.target, 'r') as z: z.setpassword(password) - return z.namelist() + self.files = z.namelist() + return self.files def verify(self, password=None): @@ -63,6 +64,8 @@ class UnZip(Extractor): with zipfile.ZipFile(self.target, 'r') as z: z.setpassword(password) z.extractall(self.dest) + self.files = z.namelist() + return self.files except RuntimeError, e: raise ArchiveError(e) |