summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal/UnZip.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-16 23:02:20 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-16 23:02:20 +0100
commitb18bf426955d85d6cb3d046aa8b074dfe56340c1 (patch)
treec0a4086bc24e57c93f8f53159c27caa8cd6a2d84 /module/plugins/internal/UnZip.py
parent[XFSHoster] Improve SIZE_PATTERN (diff)
downloadpyload-b18bf426955d85d6cb3d046aa8b074dfe56340c1.tar.xz
[UnZip] Password support
Diffstat (limited to 'module/plugins/internal/UnZip.py')
-rw-r--r--module/plugins/internal/UnZip.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py
index 053946dbe..52e279ccf 100644
--- a/module/plugins/internal/UnZip.py
+++ b/module/plugins/internal/UnZip.py
@@ -3,12 +3,12 @@
import sys
import zipfile
-from module.plugins.internal.AbstractExtractor import AbtractExtractor
+from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPassword, ArchiveError
class UnZip(AbtractExtractor):
__name__ = "UnZip"
- __version__ = "0.10"
+ __version__ = "0.11"
__description__ = """Zip extractor plugin"""
__license__ = "GPLv3"
@@ -32,9 +32,19 @@ class UnZip(AbtractExtractor):
def extract(self, progress, password=None):
- z = zipfile.ZipFile(self.file)
- self.files = z.namelist()
- z.extractall(self.out)
+ try:
+ z = zipfile.ZipFile(self.file)
+ self.files = z.namelist()
+ z.extractall(self.out, pwd=password)
+
+ except (BadZipfile, LargeZipFile), e:
+ raise ArchiveError(e)
+
+ except RuntimeError, e:
+ if e is "Bad password for file":
+ raise WrongPassword
+ else:
+ raise ArchiveError(e)
def getDeleteFiles(self):