diff options
| author | 2014-09-25 20:59:30 +0200 | |
|---|---|---|
| committer | 2014-09-25 20:59:30 +0200 | |
| commit | 31ea85f97571cc191fe205f6b4d85b3777818240 (patch) | |
| tree | 13182fa43a82a32e833acf231a340b06a3571cd7 /module/plugins/internal | |
| parent | [ZippyshareCom] Improve __pattern__ a bit (diff) | |
| download | pyload-31ea85f97571cc191fe205f6b4d85b3777818240.tar.xz | |
Extend ExtractArchive events + code optimizations
https://github.com/pyload/pyload/pull/622
https://github.com/pyload/pyload/pull/726
Diffstat (limited to 'module/plugins/internal')
| -rw-r--r-- | module/plugins/internal/UnRar.py | 31 | 
1 files changed, 20 insertions, 11 deletions
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 19c278735..91be69433 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -4,7 +4,7 @@ import os  import re  from glob import glob -from os.path import join +from os import basename, join  from string import digits  from subprocess import Popen, PIPE @@ -12,14 +12,23 @@ from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPas  from module.utils import save_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.17"      __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"  | 
