diff options
Diffstat (limited to 'pyload/plugins')
-rw-r--r-- | pyload/plugins/Account.py | 7 | ||||
-rw-r--r-- | pyload/plugins/Base.py | 2 | ||||
-rw-r--r-- | pyload/plugins/addons/MultiHoster.py | 42 | ||||
-rw-r--r-- | pyload/plugins/hoster/Premium4Me.py | 4 |
4 files changed, 33 insertions, 22 deletions
diff --git a/pyload/plugins/Account.py b/pyload/plugins/Account.py index ed0769fb4..d62825cad 100644 --- a/pyload/plugins/Account.py +++ b/pyload/plugins/Account.py @@ -212,9 +212,6 @@ class Account(Base): finally: req.close() - self.logDebug("Account Info: %s" % str(infos)) - self.timestamp = time() - self.restoreDefaults() # reset to initial state if type(infos) == dict: # copy result from dict to class for k, v in infos.iteritems(): @@ -223,6 +220,10 @@ class Account(Base): else: self.logDebug("Unknown attribute %s=%s" % (k, v)) + self.logDebug("Account Info: %s" % str(infos)) + self.timestamp = time() + self.core.evm.dispatchEvent("account:loaded", self.toInfoData()) + #TODO: remove user def loadAccountInfo(self, req): """ Overwrite this method and set account attributes within this method. diff --git a/pyload/plugins/Base.py b/pyload/plugins/Base.py index abb59a7bc..ae8614b0d 100644 --- a/pyload/plugins/Base.py +++ b/pyload/plugins/Base.py @@ -73,7 +73,7 @@ class Base(object): #: Url to service (to buy premium) for accounts __ref_url__ = "" - __author_name__ = tuple() + __author__ = tuple() __author_mail__ = tuple() diff --git a/pyload/plugins/addons/MultiHoster.py b/pyload/plugins/addons/MultiHoster.py index 2d4029dd6..f3d88a50d 100644 --- a/pyload/plugins/addons/MultiHoster.py +++ b/pyload/plugins/addons/MultiHoster.py @@ -2,12 +2,13 @@ # -*- coding: utf-8 -*- import re -from types import MethodType +from random import choice from pyload.plugins.MultiHoster import MultiHoster as MultiHosterAccount, normalize from pyload.plugins.Addon import Addon, AddEventListener from pyload.PluginManager import PluginMatcher + class MultiHoster(Addon, PluginMatcher): __version__ = "0.1" __internal__ = True @@ -17,13 +18,26 @@ class MultiHoster(Addon, PluginMatcher): __author_mail__ = ("support@pyload.org",) #TODO: multiple accounts - multihoster / config options - # TODO: rewrite for new plugin manager def init(self): - - # overwritten plugins + # overwritten plugins mapped to list of multihoster self.plugins = {} + # multihoster mapped to new regexp + self.regexp = {} + + def matchURL(self, url): + """ Overwritten to include new plugin regexp """ + for hoster, regexp in self.regexp.iteritems(): + if regexp.search(url): + return "hoster", hoster + + def matchPlugin(self, plugin, name): + """ Overwritten to overwrite already supported plugins """ + # Chooses a random multi hoster plugin + if name in self.plugins: + return plugin, choice(self.plugins[name]) + def addHoster(self, account): self.logInfo(_("Activated %s") % account.__name__) @@ -47,12 +61,15 @@ class MultiHoster(Addon, PluginMatcher): account.logError(_("No Hoster loaded")) return - klass = self.core.pluginManager.getPluginClass(account.__name__) + klass = self.core.pluginManager.getPluginClass("hoster", account.__name__, overwrite=False) # inject plugin plugin account.logDebug("Overwritten Hosters: %s" % ", ".join(sorted(supported))) for hoster in supported: - self.plugins[hoster] = klass + if hoster in self.plugins: + self.plugins[hoster].append(klass.__name__) + else: + self.plugins[hoster] = [klass.__name__] account.logDebug("New Hosters: %s" % ", ".join(sorted(new_supported))) @@ -62,13 +79,7 @@ class MultiHoster(Addon, PluginMatcher): if klass.__pattern__: patterns.append(klass.__pattern__) - regexp = r".*(%s).*" % "|".join(patterns) - - # recreate plugin tuple for new regexp - hoster = self.core.pluginManager.getPlugins("hoster") - p = hoster[account.__name__] - new = PluginTuple(p.version, re.compile(regexp), p.deps, p.category, p.user, p.path) - hoster[account.__name__] = new + self.regexp[klass.__name__] = re.compile(r".*(%s).*" % "|".join(patterns)) @AddEventListener("account:deleted") @@ -80,7 +91,7 @@ class MultiHoster(Addon, PluginMatcher): if isinstance(account, MultiHosterAccount) and account.isUsable(): self.addHoster(account) - @AddEventListener("account:updated") + @AddEventListener("account:loaded") def refreshAccount(self, acc): account = self.core.accountManager.getAccount(acc.plugin, acc.loginname) @@ -89,9 +100,8 @@ class MultiHoster(Addon, PluginMatcher): def activate(self): self.refreshAccounts() - self.core.pluginManager.addMatcher(self) - def deactivate(self): + def deactivate(self): self.core.pluginManager.removeMatcher(self) diff --git a/pyload/plugins/hoster/Premium4Me.py b/pyload/plugins/hoster/Premium4Me.py index d6c154693..b3920192c 100644 --- a/pyload/plugins/hoster/Premium4Me.py +++ b/pyload/plugins/hoster/Premium4Me.py @@ -5,8 +5,8 @@ from urllib import quote from os.path import exists from os import remove -from module.plugins.Hoster import Hoster -from module.utils import fs_encode +from pyload.plugins.Hoster import Hoster +from pyload.utils.fs import fs_encode class Premium4Me(Hoster): |