From 6260e02b65d3be072c8392c3b2e36ef47d215c41 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 2 Apr 2013 16:52:03 +0200 Subject: Unrar also deletes .r* files --- module/plugins/internal/UnRar.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal/UnRar.py') diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 240dc0233..ef04f558e 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -28,12 +28,13 @@ from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPas class UnRar(AbtractExtractor): __name__ = "UnRar" - __version__ = "0.11" + __version__ = "0.12" # there are some more uncovered rar formats - re_splitfile = re.compile(r"(.*)\.part(\d+)\.rar$") + re_splitfile = re.compile(r"(.*)\.part(\d+)\.rar$", re.I) + re_partfiles = re.compile(r".*\.(rar|r[0-9]+)", re.I) re_filelist = re.compile(r"(.+)\s+(\d+)\s+(\d+)\s+") - re_wrongpwd = re.compile("(Corrupt file or wrong password|password incorrect)") + re_wrongpwd = re.compile("(Corrupt file or wrong password|password incorrect)", re.I) CMD = "unrar" @staticmethod @@ -139,7 +140,9 @@ class UnRar(AbtractExtractor): def getDeleteFiles(self): if ".part" in self.file: return glob(re.sub("(?<=\.part)([01]+)", "*", self.file, re.IGNORECASE)) - return [self.file] + # 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" -- cgit v1.2.3 From 12741a9f656cd5a0a96c29ed63a2988c5c2be9da Mon Sep 17 00:00:00 2001 From: nilo Date: Wed, 3 Apr 2013 14:04:03 +0200 Subject: added progress to unrar --- module/plugins/internal/UnRar.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/UnRar.py') diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index ef04f558e..ef31fbae2 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -114,15 +114,31 @@ class UnRar(AbtractExtractor): def extract(self, progress, password=None): command = "x" if self.fullpath else "e" - # popen thinks process is still alive (just like pexpect) - very strange behavior - # so for now progress can not be determined correctly p = self.call_unrar(command, self.file, self.out, password=password) renice(p.pid, self.renice) progress(0) - out, err = p.communicate() #wait for process + progressstring = "" + while True: + c = p.stdout.read(1) + # quit loop on eof + if not c: + break + # reading a percentage sign -> set progress and restart + if c == '%': + progress(int(progressstring)) + progressstring = "" + # not reading a digit -> therefore restart + elif re.match('[0-9]',c) is None: + progressstring = "" + # add digit to progressstring + else: + progressstring = progressstring + c progress(100) + # retrieve stderr + err = p.stderr.read() + if "CRC failed" in err and not password and not self.passwordProtected: raise CRCError elif "CRC failed" in err: -- cgit v1.2.3 From 440733c1d96249a66e7f5d1bde1fd54770af0d56 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 3 Apr 2013 18:22:47 +0200 Subject: avoid regexp to check progress --- module/plugins/internal/UnRar.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins/internal/UnRar.py') diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index ef31fbae2..f11a49854 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -22,6 +22,7 @@ import re from os.path import join from glob import glob from subprocess import Popen, PIPE +from string import digits from module.utils import save_join, decode from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPassword, ArchiveError, CRCError @@ -129,7 +130,7 @@ class UnRar(AbtractExtractor): progress(int(progressstring)) progressstring = "" # not reading a digit -> therefore restart - elif re.match('[0-9]',c) is None: + elif c not in digits: progressstring = "" # add digit to progressstring else: -- cgit v1.2.3 From 730f038ae33d324258080b2162fe33fcfc5ccbc2 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 3 Apr 2013 19:11:51 +0200 Subject: bump unrar version --- module/plugins/internal/UnRar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/UnRar.py') diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index f11a49854..da8e7cf3d 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -29,7 +29,7 @@ from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPas class UnRar(AbtractExtractor): __name__ = "UnRar" - __version__ = "0.12" + __version__ = "0.13" # there are some more uncovered rar formats re_splitfile = re.compile(r"(.*)\.part(\d+)\.rar$", re.I) -- cgit v1.2.3