diff options
author | Jens Hörnlein <jens.hoernlein@googlemail.com> | 2015-02-08 13:47:59 +0100 |
---|---|---|
committer | Jens Hörnlein <jens.hoernlein@googlemail.com> | 2015-02-09 23:36:28 +0100 |
commit | 2a809297f288a585d96af0d8afd894c2a2f695fb (patch) | |
tree | 2b9d53e140977c25023059db5be9ea91469dd556 | |
parent | [ExtractArchive] Fix: Show Status/Progressbar (diff) | |
download | pyload-2a809297f288a585d96af0d8afd894c2a2f695fb.tar.xz |
[ExtractArchive] correct fullpath behavior, bugfix
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 16 | ||||
-rw-r--r-- | module/plugins/internal/Extractor.py | 4 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 26 |
3 files changed, 29 insertions, 17 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 81655b108..6c0177ae9 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.26" + __version__ = "1.27" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -258,14 +258,14 @@ class ExtractArchive(Hook): matched = False success = True - files_ids = [(save_join(dl, pypack.folder, pylink['name']), pylink['id']) for pylink in pypack.getChildren().itervalues()] + files_ids = [(save_join(dl, pypack.folder, pylink['name']), pylink['id'], out) for pylink in pypack.getChildren().itervalues()] # check as long there are unseen files while files_ids: new_files_ids = [] if extensions: - files_ids = [(fname, fid) for fname, fid in files_ids \ + files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ if filter(lambda ext: fname.lower().endswith(ext), extensions)] for Extractor in self.extractors: @@ -274,7 +274,7 @@ class ExtractArchive(Hook): self.logDebug("Targets for %s: %s" % (Extractor.__name__, targets)) matched = True - for fname, fid in targets: + for fname, fid, fout in targets: name = os.path.basename(fname) pname = replace_patterns(fname, self.NAME_REPLACEMENTS) @@ -283,16 +283,16 @@ class ExtractArchive(Hook): else: self.logDebug(name, "Skipped") continue - + if not os.path.exists(fname): self.logDebug(name, "File not found") continue - self.logInfo(name, _("Extract to: %s") % out) + self.logInfo(name, _("Extract to: %s") % fout) try: archive = Extractor(self, fname, - out, + fout, fullpath, overwrite, excludefiles, @@ -319,7 +319,7 @@ class ExtractArchive(Hook): continue if recursive and os.path.isfile(file): - new_files_ids.append((filename, fid)) # append as new target + new_files_ids.append((filename, fid, os.path.dirname(filename))) # append as new target files_ids = new_files_ids # also check extracted files diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 45c13c159..a5a8756d8 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -19,7 +19,7 @@ class PasswordError(Exception): class Extractor: __name__ = "Extractor" - __version__ = "0.18" + __version__ = "0.19" __description__ = """Base extractor plugin""" __license__ = "GPLv3" @@ -50,7 +50,7 @@ class Extractor: :param files_ids: List of filepathes :return: List of targets, id tuple list """ - return [(fname, id) for fname, id in files_ids if cls.isArchive(fname)] + return [(fname, id, fout) for fname, id, fout in files_ids if cls.isArchive(fname)] def __init__(self, manager, filename, out, diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 81cfb38a7..0ba990006 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -22,7 +22,7 @@ def renice(pid, value): class UnRar(Extractor): __name__ = "UnRar" - __version__ = "1.10" + __version__ = "1.11" __description__ = """Rar extractor plugin""" __license__ = "GPLv3" @@ -37,15 +37,16 @@ class UnRar(Extractor): ".ace", ".uue", ".jar", ".iso", ".7z", ".xz", ".z"] #@NOTE: there are some more uncovered rar formats - re_rarpart1 = re.compile(r'\.part(\d+)\.rar$', re.I) - re_rarpart2 = re.compile(r'\.r(\d+)$', re.I) + re_rarpart1 = re.compile(r'\.part(\d+)\.rar$', re.I) + re_rarpart2 = re.compile(r'\.r(\d+)$', re.I) re_filefixed = re.compile(r'Building (.+)') - re_filelist = re.compile(r'(.+)\s+(\D+)\s+(\d+)\s+\d\d-\d\d-\d\d\s+\d\d:\d\d\s+(.+)') + re_filelist = re.compile(r'(.+)\s+(\d+)\s+\d\d-\d\d-\d\d\s+\d\d:\d\d\s+(.+)') re_wrongpwd = re.compile(r'password', re.I) re_wrongcrc = re.compile(r'encrypted|damaged|CRC failed|checksum error', re.I) + re_version = re.compile(r'UNRAR\s(\d+)\.\d+', re.I) @classmethod def isUsable(cls): @@ -185,6 +186,10 @@ class UnRar(Extractor): def list(self, password=None): command = "vb" if self.fullpath else "lb" + p = self.call_cmd("", "", fs_encode(self.filename)) + out, err = p.communicate() + version = self.re_version.search(out).group(1) + p = self.call_cmd(command, "-v", fs_encode(self.filename), password=password) out, err = p.communicate() @@ -195,9 +200,16 @@ class UnRar(Extractor): self.manager.logError(err.strip()) result = set() - for f in decode(out).splitlines(): - f = f.strip() - result.add(save_join(self.out, f)) + if not self.fullpath and version =='5': + # NOTE: Unrar 5 always list full path + for f in decode(out).splitlines(): + f = save_join(self.out, os.path.basename(f.strip())) + if os.path.isfile(f): + result.add(save_join(self.out, os.path.basename(f))) + else: + for f in decode(out).splitlines(): + f = f.strip() + result.add(save_join(self.out, f)) return list(result) |