summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/AbstractExtractor.py29
-rw-r--r--module/plugins/internal/UnRar.py54
-rw-r--r--module/plugins/internal/UnZip.py15
3 files changed, 47 insertions, 51 deletions
diff --git a/module/plugins/internal/AbstractExtractor.py b/module/plugins/internal/AbstractExtractor.py
index 2317ad689..c8a73c861 100644
--- a/module/plugins/internal/AbstractExtractor.py
+++ b/module/plugins/internal/AbstractExtractor.py
@@ -14,23 +14,24 @@ class WrongPassword(Exception):
class AbtractExtractor:
__name__ = "AbtractExtractor"
- __version__ = "0.10"
+ __version__ = "0.11"
__description__ = """Abtract extractor plugin"""
__license__ = "GPLv3"
- __authors__ = [("pyLoad Team", "admin@pyload.org")]
+ __authors__ = [("RaNaN", "ranan@pyload.org"),
+ ("Walter Purcaro", "vuolter@gmail.com")]
- @staticmethod
- def checkDeps():
+ @classmethod
+ def checkDeps(cls):
""" Check if system statisfy dependencies
:return: boolean
"""
return True
- @staticmethod
- def getTargets(files_ids):
+ @classmethod
+ def getTargets(cls, files_ids):
""" Filter suited targets from list of filename id tuple list
:param files_ids: List of filepathes
:return: List of targets, id tuple list
@@ -48,14 +49,14 @@ class AbtractExtractor:
:param overwrite: Overwrite existing archives
:param renice: Renice value
"""
- self.m = m
- self.file = file
- self.out = out
- self.fullpath = fullpath
- self.overwrite = overwrite
+ self.m = m
+ self.file = file
+ self.out = out
+ self.fullpath = fullpath
+ self.overwrite = overwrite
self.excludefiles = excludefiles
- self.renice = renice
- self.files = [] #: Store extracted files here
+ self.renice = renice
+ self.files = [] #: Store extracted files here
def init(self):
@@ -83,7 +84,7 @@ class AbtractExtractor:
return True
- def extract(self, progress, password=None):
+ def extract(self, progress, password=""):
"""Extract the archive. Raise specific errors in case of failure.
:param progress: Progress function, call this to update status
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index 716a62613..4bbd2042c 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -22,53 +22,52 @@ def renice(pid, value):
class UnRar(AbtractExtractor):
__name__ = "UnRar"
- __version__ = "0.20"
+ __version__ = "0.21"
__description__ = """Rar extractor plugin"""
__license__ = "GPLv3"
- __authors__ = [("RaNaN", "RaNaN@pyload.org")]
+ __authors__ = [("RaNaN", "RaNaN@pyload.org"),
+ ("Walter Purcaro", "vuolter@gmail.com")]
CMD = "unrar"
- # there are some more uncovered rar formats
- re_version = re.compile(r'UNRAR ([\w .]+?)')
+ #@NOTE: there are some more uncovered rar formats
re_splitfile = re.compile(r'(.*)\.part(\d+)\.rar$', re.I)
re_partfiles = re.compile(r'.*\.(rar|r\d+)', re.I)
- re_filelist = re.compile(r'(.+)\s+(\d+)\s+(\d+)\s+')
- re_filelist5 = re.compile(r'(.+)\s+(\d+)\s+\d\d-\d\d-\d\d\s+\d\d:\d\d\s+(.+)')
+ re_filelist = re.compile(r'(.+)\s+(\d+)\s+(\d+)\s+|(.+)\s+(\d+)\s+\d\d-\d\d-\d\d\s+\d\d:\d\d\s+(.+)')
re_wrongpwd = re.compile(r'(Corrupt file or wrong password|password incorrect)', re.I)
- @staticmethod
- def checkDeps():
+ @classmethod
+ def checkDeps(cls):
if os.name == "nt":
- UnRar.CMD = join(pypath, "UnRAR.exe")
- p = Popen([UnRar.CMD], stdout=PIPE, stderr=PIPE)
+ cls.CMD = join(pypath, "UnRAR.exe")
+ p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE)
p.communicate()
else:
try:
- p = Popen([UnRar.CMD], stdout=PIPE, stderr=PIPE)
+ p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE)
p.communicate()
- except OSError:
+ except OSError:
# fallback to rar
- UnRar.CMD = "rar"
- p = Popen([UnRar.CMD], stdout=PIPE, stderr=PIPE)
+ cls.CMD = "rar"
+ p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE)
p.communicate()
return True
- @staticmethod
- def getTargets(files_ids):
+ @classmethod
+ def getTargets(cls, files_ids):
result = []
for file, id in files_ids:
if not file.endswith(".rar"):
continue
- match = UnRar.re_splitfile.findall(file)
+ match = cls.re_splitfile.findall(file)
if match:
# only add first parts
if int(match[0][1]) == 1:
@@ -81,9 +80,8 @@ class UnRar(AbtractExtractor):
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
+ self.headerProtected = False #: list files will not work without password
+ self.password = "" #: save the correct password
def checkArchive(self):
@@ -95,16 +93,10 @@ class UnRar(AbtractExtractor):
return True
# output only used to check if passworded files are present
- if self.re_version.search(out):
- for attr, size, name in self.re_filelist5.findall(out):
- if attr.startswith("*"):
- self.passwordProtected = True
- return True
- else:
- for name, size, packed in self.re_filelist.findall(out):
- if name.startswith("*"):
- self.passwordProtected = True
- return True
+ for attr in self.re_filelist.findall(out):
+ if attr[0].startswith("*"):
+ self.passwordProtected = True
+ return True
self.listContent()
if not self.files:
@@ -131,6 +123,7 @@ class UnRar(AbtractExtractor):
renice(p.pid, self.renice)
progress(0)
+
progressstring = ""
while True:
c = p.stdout.read(1)
@@ -147,6 +140,7 @@ class UnRar(AbtractExtractor):
# add digit to progressstring
else:
progressstring = progressstring + c
+
progress(100)
# retrieve stderr
diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py
index 52e279ccf..81c298784 100644
--- a/module/plugins/internal/UnZip.py
+++ b/module/plugins/internal/UnZip.py
@@ -8,20 +8,21 @@ from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPas
class UnZip(AbtractExtractor):
__name__ = "UnZip"
- __version__ = "0.11"
+ __version__ = "0.12"
__description__ = """Zip extractor plugin"""
__license__ = "GPLv3"
- __authors__ = [("RaNaN", "RaNaN@pyload.org")]
+ __authors__ = [("RaNaN", "RaNaN@pyload.org"),
+ ("Walter Purcaro", "vuolter@gmail.com")]
- @staticmethod
- def checkDeps():
+ @classmethod
+ def checkDeps(cls):
return sys.version_info[:2] >= (2, 6)
- @staticmethod
- def getTargets(files_ids):
+ @classmethod
+ def getTargets(cls, files_ids):
result = []
for file, id in files_ids:
@@ -31,7 +32,7 @@ class UnZip(AbtractExtractor):
return result
- def extract(self, progress, password=None):
+ def extract(self, progress, password=""):
try:
z = zipfile.ZipFile(self.file)
self.files = z.namelist()