diff options
| -rw-r--r-- | module/plugins/internal/UnRar.py | 22 | 
1 files changed, 19 insertions, 3 deletions
| 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: | 
