summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r--module/plugins/hooks/ClickAndLoad.py2
-rw-r--r--module/plugins/hooks/Ev0InFetcher.py2
-rw-r--r--module/plugins/hooks/ExternalScripts.py9
-rw-r--r--module/plugins/hooks/ExtractArchive.py5
-rw-r--r--module/plugins/hooks/MultiHoster.py101
-rw-r--r--module/plugins/hooks/RealdebridCom.py24
-rw-r--r--module/plugins/hooks/UpdateManager.py11
-rw-r--r--module/plugins/hooks/XMPPInterface.py31
8 files changed, 145 insertions, 40 deletions
diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py
index 97e5cd57d..fc32d0da8 100644
--- a/module/plugins/hooks/ClickAndLoad.py
+++ b/module/plugins/hooks/ClickAndLoad.py
@@ -32,7 +32,7 @@ class ClickAndLoad(Hook):
__author_name__ = ("RaNaN", "mkaay")
__author_mail__ = ("RaNaN@pyload.de", "mkaay@mkaay.de")
- def coreReady(self):
+ def activate(self):
self.port = int(self.core.config['webinterface']['port'])
if self.core.config['webinterface']['activated']:
try:
diff --git a/module/plugins/hooks/Ev0InFetcher.py b/module/plugins/hooks/Ev0InFetcher.py
index 5941cf38c..0cd3f3226 100644
--- a/module/plugins/hooks/Ev0InFetcher.py
+++ b/module/plugins/hooks/Ev0InFetcher.py
@@ -40,7 +40,7 @@ class Ev0InFetcher(Hook):
results = self.core.pluginManager.parseUrls(links)
sortedLinks = {}
- for url, hoster in results:
+ for url, hoster in results[0]:
if hoster not in sortedLinks:
sortedLinks[hoster] = []
sortedLinks[hoster].append(url)
diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py
index 2e77f1dae..39fe2b9f0 100644
--- a/module/plugins/hooks/ExternalScripts.py
+++ b/module/plugins/hooks/ExternalScripts.py
@@ -14,16 +14,15 @@
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
- @author: mkaay
- @interface-version: 0.1
+ @author: RaNaN
"""
import subprocess
-from os import listdir, access, X_OK, makedirs
-from os.path import join, exists, basename
+from os import access, X_OK, makedirs
+from os.path import basename
from module.plugins.Hook import Hook
-from module.utils import save_join
+from module.utils.fs import save_join, exists, join, listdir
class ExternalScripts(Hook):
__name__ = "ExternalScripts"
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index c789495ca..12bd40d1b 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -3,8 +3,7 @@
import sys
import os
-from os import remove, chmod, makedirs
-from os.path import exists, basename, isfile, isdir, join
+from os.path import basename, isfile, isdir, join
from traceback import print_exc
from copy import copy
@@ -49,7 +48,7 @@ if os.name != "nt":
from pwd import getpwnam
from grp import getgrnam
-from module.utils import save_join, fs_encode
+from module.utils.fs import save_join, fs_encode, exists, remove, chmod, makedirs
from module.plugins.Hook import Hook, threaded, Expose
from module.plugins.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword
diff --git a/module/plugins/hooks/MultiHoster.py b/module/plugins/hooks/MultiHoster.py
new file mode 100644
index 000000000..749f2c104
--- /dev/null
+++ b/module/plugins/hooks/MultiHoster.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+from types import MethodType
+
+from module.plugins.MultiHoster import MultiHoster as MultiHosterAccount, normalize
+from module.plugins.Hook import Hook, AddEventListener
+from module.plugins.PluginManager import PluginTuple
+
+class MultiHoster(Hook):
+ __version__ = "0.1"
+ __description__ = "Gives ability to use MultiHoster services. You need to add your account first."
+ __config__ = [("activated", "bool", "Activated", True)]
+ __author_mail__ = ("pyLoad Team",)
+ __author_mail__ = ("support@pyload.org",)
+
+ #TODO: multiple accounts - multihoster / config options
+
+ def init(self):
+
+ # overwritten plugins
+ self.plugins = {}
+
+ def addHoster(self, account):
+
+ self.logDebug("New MultiHoster %s" % account.__name__)
+
+ pluginMap = {}
+ for name in self.core.pluginManager.getPlugins("hoster").keys():
+ pluginMap[name.lower()] = name
+
+ supported = []
+ new_supported = []
+
+ for hoster in account.getHosterList():
+ name = normalize(hoster)
+
+ if name in pluginMap:
+ supported.append(pluginMap[name])
+ else:
+ new_supported.append(hoster)
+
+ if not supported and not new_supported:
+ account.logError(_("No Hoster loaded"))
+ return
+
+ klass = self.core.pluginManager.getPluginClass(account.__name__)
+
+ # inject plugin plugin
+ account.logDebug("Overwritten Hosters: %s" % ", ".join(sorted(supported)))
+ for hoster in supported:
+ self.plugins[hoster] = klass
+
+ account.logDebug("New Hosters: %s" % ", ".join(sorted(new_supported)))
+
+ # create new regexp
+ regexp = r".*(%s).*" % "|".join([klass.__pattern__] + [x.replace(".", "\\.") for x in new_supported])
+
+ # 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.user, p.path)
+ hoster[account.__name__] = new
+
+
+
+ @AddEventListener("accountDeleted")
+ def refreshAccounts(self, plugin=None, user=None):
+
+ self.plugins = {}
+
+ for name, account in self.core.accountManager.iterAccounts():
+ if isinstance(account, MultiHosterAccount) and account.isUsable():
+ self.addHoster(account)
+
+ @AddEventListener("accountUpdated")
+ def refreshAccount(self, plugin, user):
+
+ account = self.core.accountManager.getAccount(plugin, user)
+ if isinstance(account, MultiHosterAccount) and account.isUsable():
+ self.addHoster(account)
+
+ def activate(self):
+ self.refreshAccounts()
+
+ # new method for plugin manager
+ def getPlugin(self2, name):
+ if name in self.plugins:
+ return self.plugins[name]
+ return self2.getPluginClass(name)
+
+ pm = self.core.pluginManager
+ pm.getPlugin = MethodType(getPlugin, pm, object)
+
+
+ def deactivate(self):
+ #restore state
+ pm = self.core.pluginManager
+ pm.getPlugin = pm.getPluginClass
+
diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py
deleted file mode 100644
index c57e3de52..000000000
--- a/module/plugins/hooks/RealdebridCom.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
-
-class RealdebridCom(MultiHoster):
- __name__ = "RealdebridCom"
- __version__ = "0.4"
- __type__ = "hook"
-
- __config__ = [("activated", "bool", "Activated", "False"),
- ("https", "bool", "Enable HTTPS", "False")]
-
- __description__ = """Real-Debrid.com hook plugin"""
- __author_name__ = ("Devirex, Hazzard")
- __author_mail__ = ("naibaf_11@yahoo.de")
-
- replacements = [("freakshare.net", "freakshare.com")]
-
- def getHoster(self):
- https = "https" if self.getConfig("https") else "http"
- page = getURL(https + "://real-debrid.com/api/hosters.php").replace("\"","").strip()
-
- return[x.strip() for x in page.split(",") if x.strip()] \ No newline at end of file
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
index ce75399c5..230a6e858 100644
--- a/module/plugins/hooks/UpdateManager.py
+++ b/module/plugins/hooks/UpdateManager.py
@@ -23,7 +23,7 @@ from os import stat
from os.path import join, exists
from time import time
-from module.ConfigParser import IGNORE
+from module.plugins.PluginManager import IGNORE
from module.network.RequestFactory import getURL
from module.plugins.Hook import threaded, Expose, Hook
@@ -60,6 +60,11 @@ class UpdateManager(Hook):
@threaded
def periodical(self):
+
+ if self.core.version.endswith("-dev"):
+ self.logDebug("No update check performed on dev version.")
+ return
+
update = self.checkForUpdate()
if update:
self.info["pyload"] = True
@@ -129,10 +134,10 @@ class UpdateManager(Hook):
else:
type = prefix
- plugins = getattr(self.core.pluginManager, "%sPlugins" % type)
+ plugins = self.core.pluginManager.getPlugins(type)
if name in plugins:
- if float(plugins[name]["v"]) >= float(version):
+ if float(plugins[name].version) >= float(version):
continue
if name in IGNORE or (type, name) in IGNORE:
diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py
index a96adf524..de87433cf 100644
--- a/module/plugins/hooks/XMPPInterface.py
+++ b/module/plugins/hooks/XMPPInterface.py
@@ -19,7 +19,7 @@
"""
from pyxmpp import streamtls
-from pyxmpp.all import JID, Message
+from pyxmpp.all import JID, Message, Presence
from pyxmpp.jabber.client import JabberClient
from pyxmpp.interface import implements
from pyxmpp.interfaces import *
@@ -121,7 +121,26 @@ class XMPPInterface(IRCInterface, JabberClient):
in a client session."""
return [
("normal", self.message),
- ]
+ ]
+
+ def presence_control(self, stanza):
+ from_jid = unicode(stanza.get_from_jid())
+ stanza_type = stanza.get_type()
+ self.log.debug("pyLoad XMPP: %s stanza from %s" % (stanza_type,
+ from_jid))
+
+ if from_jid in self.getConfig("owners"):
+ return stanza.make_accept_response()
+
+ return stanza.make_deny_response()
+
+ def session_started(self):
+ self.stream.send(Presence())
+
+ self.stream.set_presence_handler("subscribe", self.presence_control)
+ self.stream.set_presence_handler("subscribed", self.presence_control)
+ self.stream.set_presence_handler("unsubscribe", self.presence_control)
+ self.stream.set_presence_handler("unsubscribed", self.presence_control)
def message(self, stanza):
"""Message handler for the component."""
@@ -248,4 +267,10 @@ class VersionHandler(object):
q.newTextChild(q.ns(), "name", "Echo component")
q.newTextChild(q.ns(), "version", "1.0")
return iq
- \ No newline at end of file
+
+ def unload(self):
+ self.log.debug("pyLoad XMPP: unloading")
+ self.disconnect()
+
+ def deactivate(self):
+ self.unload()