summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-11-11 19:43:07 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-11-11 19:43:07 +0100
commitb0dc6482c0779aa5ba75ae339d408b75082f06f0 (patch)
tree6570a93efef82dba31b91889ec813b6498d4ff05 /module
parentMerged in scrool/pyload (pull request #4) (diff)
downloadpyload-b0dc6482c0779aa5ba75ae339d408b75082f06f0.tar.xz
option for subfolders
Diffstat (limited to 'module')
-rw-r--r--module/plugins/hooks/ExtractArchive.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 74721d166..0a70da417 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -3,8 +3,8 @@
import sys
import os
-from os import remove, chmod
-from os.path import exists, basename, isfile, isdir
+from os import remove, chmod, makedirs
+from os.path import exists, basename, isfile, isdir, join
from traceback import print_exc
from copy import copy
@@ -50,7 +50,7 @@ if os.name != "nt":
from grp import getgrnam
from module.plugins.Hook import Hook, threaded, Expose
-from module.utils import save_join
+from module.utils import save_join, fs_encode
class ArchiveError(Exception):
@@ -77,6 +77,7 @@ class ExtractArchive(Hook):
("overwrite", "bool", "Overwrite files", True),
("passwordfile", "file", "password file", "unrar_passwords.txt"),
("deletearchive", "bool", "Delete archives when done", False),
+ ("subfolder", "bool", "Create subfolder for each package", False),
("destination", "folder", "Extract files to", ""),
("queue", "bool", "Wait for all downloads to be fninished", True),
("renice", "int", "CPU Priority", 0), ]
@@ -159,9 +160,15 @@ class ExtractArchive(Hook):
# force trailing slash
if self.getConfig("destination") and self.getConfig("destination").lower() != "none":
- if exists(self.getConfig("destination")):
- out = save_join(dl, p.folder, self.getConfig("destination"), "")
- #relative to package folder if destination is relative, otherwise absolute path overwrites them
+
+ out = save_join(dl, p.folder, self.getConfig("destination"), "")
+ #relative to package folder if destination is relative, otherwise absolute path overwrites them
+
+ if self.getConf("subfolder"):
+ out = join(out, fs_encode(p.folder))
+
+ if not exists(out):
+ makedirs(out)
files_ids = [(save_join(dl, p.folder, x["name"]), x["id"]) for x in p.getChildren().itervalues()]