summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-10-14 20:23:23 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-10-14 20:23:23 +0200
commitd9c7f0cbe443ecfa445dad59a255a5f1dff0b6a7 (patch)
tree57b54b9875f014e662b0e5499c2277f1968dbd0d /module/plugins/hooks
parentfirst version of new extract plugin (diff)
downloadpyload-d9c7f0cbe443ecfa445dad59a255a5f1dff0b6a7.tar.xz
improved extract plugin
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r--module/plugins/hooks/ExtractArchive.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 90ee2298d..62d386c99 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -47,6 +47,7 @@ class ExtractArchive(Hook):
def setup(self):
self.plugins = []
+ self.passwords = []
names = []
for p in ("UnRar",):
@@ -91,6 +92,9 @@ class ExtractArchive(Hook):
def extract(self, ids, thread=None):
+ # reload from txt file
+ self.reloadPasswords()
+
# dl folder
dl = self.config['general']['download_folder']
@@ -175,7 +179,7 @@ class ExtractArchive(Hook):
return []
if self.core.debug:
- self.logDebug("Would delete: %s" % ",".join(plugin.getDeleteFiles()))
+ self.logDebug("Would delete: %s" % ", ".join(plugin.getDeleteFiles()))
if self.getConfig("deletearchive"):
files = plugin.getDeleteFiles()
@@ -204,34 +208,34 @@ class ExtractArchive(Hook):
@Expose
def getPasswords(self):
""" List of saved passwords """
+ return self.passwords
+
+
+ def reloadPasswords(self):
pwfile = self.getConfig("passwordfile")
if not exists(pwfile):
open(pwfile, "wb").close()
passwords = []
f = open(pwfile, "rb")
- for pw in f.readline():
+ for pw in f.read().splitlines():
passwords.append(pw)
f.close()
- return passwords
+ self.passwords = passwords
+
@Expose
def addPassword(self, pw):
""" Adds a password to saved list"""
pwfile = self.getConfig("passwordfile")
- passwords = []
- f = open(pwfile, "rb")
- for pw in f.readline():
- passwords.append(pw)
- f.close()
-
- if pw in passwords: passwords.remove(pw)
- passwords.insert(0, pw)
+ if pw in self.passwords: self.passwords.remove(pw)
+ self.passwords.insert(0, pw)
f = open(pwfile, "wb")
- f.writelines(passwords)
+ for pw in self.passwords:
+ f.write(pw + "\n")
f.close()
def setPermissions(self, files):