diff options
Diffstat (limited to 'pyload/plugins/internal/UnRar.py')
-rw-r--r-- | pyload/plugins/internal/UnRar.py | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/pyload/plugins/internal/UnRar.py b/pyload/plugins/internal/UnRar.py index ed8478a3a..0f54e75b9 100644 --- a/pyload/plugins/internal/UnRar.py +++ b/pyload/plugins/internal/UnRar.py @@ -4,7 +4,7 @@ import os import re from glob import glob -from os.path import join +from os.path import basename, join from string import digits from subprocess import Popen, PIPE @@ -12,14 +12,23 @@ from pyload.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPas from pyload.utils import safe_join, decode +def renice(pid, value): + if os.name != "nt" and value: + try: + Popen(["renice", str(value), str(pid)], stdout=PIPE, stderr=PIPE, bufsize=-1) + except: + print "Renice failed" + + class UnRar(AbtractExtractor): __name__ = "UnRar" - __version__ = "0.16" + __version__ = "0.18" __description__ = """Rar extractor plugin""" __author_name__ = "RaNaN" __author_mail__ = "RaNaN@pyload.org" + CMD = "unrar" # there are some more uncovered rar formats @@ -50,6 +59,7 @@ class UnRar(AbtractExtractor): return True + @staticmethod def getTargets(files_ids): result = [] @@ -68,12 +78,14 @@ class UnRar(AbtractExtractor): return result + def init(self): self.passwordProtected = False self.headerProtected = False #: list files will not work without password self.smallestFile = None #: small file to test passwords self.password = "" #: save the correct password + def checkArchive(self): p = self.call_unrar("l", "-v", self.file) out, err = p.communicate() @@ -100,6 +112,7 @@ class UnRar(AbtractExtractor): return False + def checkPassword(self, password): # at this point we can only verify header protected files if self.headerProtected: @@ -110,6 +123,7 @@ class UnRar(AbtractExtractor): return True + def extract(self, progress, password=None): command = "x" if self.fullpath else "e" @@ -151,13 +165,15 @@ class UnRar(AbtractExtractor): self.password = password self.listContent() + def getDeleteFiles(self): - if ".part" in self.file: + if ".part" in basename(self.file): return glob(re.sub("(?<=\.part)([01]+)", "*", self.file, re.IGNORECASE)) # get files which matches .r* and filter unsuited files out parts = glob(re.sub(r"(?<=\.r)ar$", "*", self.file, re.IGNORECASE)) return filter(lambda x: self.re_partfiles.match(x), parts) + def listContent(self): command = "vb" if self.fullpath else "lb" p = self.call_unrar(command, "-v", self.file, password=self.password) @@ -177,6 +193,7 @@ class UnRar(AbtractExtractor): self.files = result + def call_unrar(self, command, *xargs, **kwargs): args = [] # overwrite flag @@ -202,11 +219,3 @@ class UnRar(AbtractExtractor): p = Popen(call, stdout=PIPE, stderr=PIPE) return p - - -def renice(pid, value): - if os.name != "nt" and value: - try: - Popen(["renice", str(value), str(pid)], stdout=PIPE, stderr=PIPE, bufsize=-1) - except: - print "Renice failed" |