diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-11-22 23:00:43 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-11-22 23:00:43 +0100 |
commit | 7a386102e272abf12fc8a03733538421b2711045 (patch) | |
tree | 4d1f1ef511bf3e3b3d95f78d35067885deffc01e /pyload/plugins/addons/ExtractArchive.py | |
parent | fixed and improved last pull request (diff) | |
download | pyload-7a386102e272abf12fc8a03733538421b2711045.tar.xz |
improved addonManager, new property to expose addon information, new functionality to interact with addons
Diffstat (limited to 'pyload/plugins/addons/ExtractArchive.py')
-rw-r--r-- | pyload/plugins/addons/ExtractArchive.py | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/pyload/plugins/addons/ExtractArchive.py b/pyload/plugins/addons/ExtractArchive.py index be023301c..67fa5c820 100644 --- a/pyload/plugins/addons/ExtractArchive.py +++ b/pyload/plugins/addons/ExtractArchive.py @@ -49,12 +49,13 @@ if os.name != "nt": from pwd import getpwnam from grp import getgrnam -from module.utils import save_join, fs_encode -from module.plugins.Hook import Hook, threaded, Expose -from module.plugins.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword +from pyload.utils.fs import safe_join as save_join, fs_encode +from pyload.plugins.Addon import Addon, threaded, AddonHandler, AddonProperty +from pyload.plugins.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword -class ExtractArchive(Hook): + +class ExtractArchive(Addon): """ Provides: unrarFinished (folder, filename) """ @@ -77,7 +78,7 @@ class ExtractArchive(Hook): event_list = ["allDownloadsProcessed"] - def setup(self): + def init(self): self.plugins = [] self.passwords = [] names = [] @@ -111,10 +112,10 @@ class ExtractArchive(Hook): # queue with package ids self.queue = [] - @Expose - def extractPackage(self, id): + @AddonHandler(_("Extract package"), _("Scans package for archives and extract them")) + def extractPackage(self, pid): """ Extract package with given id""" - self.manager.startThread(self.extract, [id]) + self.manager.startThread(self.extract, [pid]) def packageFinished(self, pypack): if self.getConfig("queue"): @@ -267,25 +268,12 @@ class ExtractArchive(Hook): return [] - @Expose + # TODO: config handler for passwords? + 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.read().splitlines(): - passwords.append(pw) - f.close() - - self.passwords = passwords - - @Expose def addPassword(self, pw): """ Adds a password to saved list""" pwfile = self.getConfig("passwordfile") @@ -299,6 +287,19 @@ class ExtractArchive(Hook): f.write(pw + "\n") f.close() + def reloadPasswords(self): + pwfile = self.getConfig("passwordfile") + if not exists(pwfile): + open(pwfile, "wb").close() + + passwords = [] + f = open(pwfile, "rb") + for pw in f.read().splitlines(): + passwords.append(pw) + f.close() + + self.passwords = passwords + def setPermissions(self, files): for f in files: if not exists(f): |