summaryrefslogtreecommitdiffstats
path: root/pyload/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugins')
-rw-r--r--pyload/plugins/Addon.py15
-rw-r--r--pyload/plugins/Base.py3
-rw-r--r--pyload/plugins/Crypter.py27
-rw-r--r--pyload/plugins/Hoster.py2
-rw-r--r--pyload/plugins/addons/ClickAndLoad.py18
-rw-r--r--pyload/plugins/addons/ExternalScripts.py27
-rw-r--r--pyload/plugins/addons/ExtractArchive.py2
7 files changed, 45 insertions, 49 deletions
diff --git a/pyload/plugins/Addon.py b/pyload/plugins/Addon.py
index 5c27fa983..da5bbc1d7 100644
--- a/pyload/plugins/Addon.py
+++ b/pyload/plugins/Addon.py
@@ -97,9 +97,6 @@ class Addon(Base):
"""
- #: automatically register event listeners for functions, attribute will be deleted don't use it yourself
- event_map = None
-
#: periodic call interval in seconds
interval = 0
@@ -112,18 +109,6 @@ class Addon(Base):
#: `AddonManager`
self.manager = manager
- #register events
- if self.event_map:
- for event, funcs in self.event_map.iteritems():
- if type(funcs) in (list, tuple):
- for f in funcs:
- self.evm.listenTo(event, getattr(self, f))
- else:
- self.evm.listenTo(event, getattr(self, funcs))
-
- #delete for various reasons
- self.event_map = None
-
self.init()
# start periodically if set
diff --git a/pyload/plugins/Base.py b/pyload/plugins/Base.py
index ae8614b0d..b6668ea90 100644
--- a/pyload/plugins/Base.py
+++ b/pyload/plugins/Base.py
@@ -105,6 +105,9 @@ class Base(object):
#: last interaction task
self.task = None
+ #: js engine, see `JsEngine`
+ self.js = self.core.js
+
def __getitem__(self, item):
""" Retrieves meta data attribute """
return getattr(self, "__%s__" % item)
diff --git a/pyload/plugins/Crypter.py b/pyload/plugins/Crypter.py
index af3d5aba7..fcea1263a 100644
--- a/pyload/plugins/Crypter.py
+++ b/pyload/plugins/Crypter.py
@@ -48,8 +48,8 @@ class Package:
return self.name == other.name and self.links == other.links
def __repr__(self):
- return u"<CrypterPackage name=%s, links=[%s], packs=%s" % (self.name, ",".join(str(l) for l in self.links),
- self.packs)
+ return u"<CrypterPackage name=%s, links=[%s], packs=%s>" % (self.name, ", ".join(str(l) for l in self.links),
+ self.packs)
def __hash__(self):
return hash(self.name) ^ hash(frozenset(self.links)) ^ hash(self.name)
@@ -58,14 +58,20 @@ class Package:
class PyFileMockup:
""" Legacy class needed by old crypter plugins """
- def __init__(self, url, pack):
+ def __init__(self, url, pack_name):
self.url = url
self.name = url
- self._package = None
- self.packageid = pack.id if pack else -1
+ self.packageid = -1
+ self.pack_name = pack_name + " Package"
def package(self):
- return self._package
+ # mockes the pyfile package
+ class PyPackage:
+ def __init__(self, f):
+ self.name = f.pack_name
+ self.folder = self.name
+
+ return PyPackage(self)
class Crypter(Base):
@@ -145,6 +151,7 @@ class Crypter(Base):
#: Password supplied by user
self.password = password
+ # TODO: removed in future
# For old style decrypter, do not use these!
self.packages = []
self.urls = []
@@ -201,7 +208,7 @@ class Crypter(Base):
self.logDebug("Deprecated .decrypt() method in Crypter plugin")
result = []
for url in urls:
- self.pyfile = PyFileMockup(url)
+ self.pyfile = PyFileMockup(url, cls.__name__)
self.setup()
self.decrypt(self.pyfile)
result.extend(self.convertPackages())
@@ -276,7 +283,11 @@ class Crypter(Base):
def convertPackages(self):
""" Deprecated """
self.logDebug("Deprecated method .convertPackages()")
- res = [Package(name, urls) for name, urls in self.packages]
+ res = []
+ for pack in self.packages:
+ # only use name and urls
+ res.append(Package(pack[0], pack[1]))
+
res.extend(self.urls)
return res
diff --git a/pyload/plugins/Hoster.py b/pyload/plugins/Hoster.py
index 6bfe47e1f..68eb32baa 100644
--- a/pyload/plugins/Hoster.py
+++ b/pyload/plugins/Hoster.py
@@ -89,8 +89,6 @@ class Hoster(Base):
self.lastDownload = ""
#: re match of the last call to `checkDownload`
self.lastCheck = None
- #: js engine, see `JsEngine`
- self.js = self.core.js
self.retries = 0 # amount of retries already made
self.html = None # some plugins store html code here
diff --git a/pyload/plugins/addons/ClickAndLoad.py b/pyload/plugins/addons/ClickAndLoad.py
index 0fc78abfe..0d9538543 100644
--- a/pyload/plugins/addons/ClickAndLoad.py
+++ b/pyload/plugins/addons/ClickAndLoad.py
@@ -21,10 +21,9 @@
import socket
import thread
-from module.plugins.Hook import Hook
+from pyload.plugins.Addon import Addon
-
-class ClickAndLoad(Hook):
+class ClickAndLoad(Addon):
__name__ = "ClickAndLoad"
__version__ = "0.22"
__description__ = """Gives abillity to use jd's click and load. depends on webinterface"""
@@ -36,15 +35,12 @@ class ClickAndLoad(Hook):
def coreReady(self):
self.port = int(self.config['webinterface']['port'])
if self.config['webinterface']['activated']:
- try:
- if self.getConfig("extern"):
- ip = "0.0.0.0"
- else:
- ip = "127.0.0.1"
+ if self.getConfig("extern"):
+ ip = "0.0.0.0"
+ else:
+ ip = "127.0.0.1"
- thread.start_new_thread(proxy, (self, ip, self.port, 9666))
- except:
- self.logError("ClickAndLoad port already in use.")
+ thread.start_new_thread(proxy, (self, ip, self.port, 9666))
def proxy(self, *settings):
diff --git a/pyload/plugins/addons/ExternalScripts.py b/pyload/plugins/addons/ExternalScripts.py
index b1a9420bb..2a95a7af0 100644
--- a/pyload/plugins/addons/ExternalScripts.py
+++ b/pyload/plugins/addons/ExternalScripts.py
@@ -20,13 +20,14 @@
import subprocess
from os import listdir, access, X_OK, makedirs
-from os.path import join, exists, basename
+from os.path import join, exists, basename, abspath
-from module.plugins.Hook import Hook
-from module.utils import save_join
+from pyload.plugins.Addon import Addon, AddEventListener
+from pyload.utils.fs import safe_join
-class ExternalScripts(Hook):
+
+class ExternalScripts(Addon):
__name__ = "ExternalScripts"
__version__ = "0.23"
__description__ = """Run external scripts"""
@@ -34,13 +35,12 @@ class ExternalScripts(Hook):
__author_name__ = ("mkaay", "RaNaN", "spoob")
__author_mail__ = ("mkaay@mkaay.de", "ranan@pyload.org", "spoob@pyload.org")
- event_list = ["unrarFinished", "allDownloadsFinished", "allDownloadsProcessed"]
- def setup(self):
+ def activate(self):
self.scripts = {}
folders = ['download_preparing', 'download_finished', 'package_finished',
- 'before_reconnect', 'after_reconnect', 'unrar_finished',
+ 'before_reconnect', 'after_reconnect', 'extracting_finished',
'all_dls_finished', 'all_dls_processed']
for folder in folders:
@@ -73,7 +73,7 @@ class ExternalScripts(Hook):
def callScript(self, script, *args):
try:
cmd = [script] + [str(x) if not isinstance(x, basestring) else x for x in args]
- self.logDebug("Executing %(script)s: %(cmd)s" % {"script": os.path.abspath(script), "cmd": " ".join(cmd)})
+ self.logDebug("Executing %(script)s: %(cmd)s" % {"script": abspath(script), "cmd": " ".join(cmd)})
#output goes to pyload
subprocess.Popen(cmd, bufsize=-1)
except Exception, e:
@@ -86,13 +86,13 @@ class ExternalScripts(Hook):
def downloadFinished(self, pyfile):
for script in self.scripts['download_finished']:
self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name,
- save_join(self.config['general']['download_folder'],
+ safe_join(self.config['general']['download_folder'],
pyfile.package().folder, pyfile.name), pyfile.id)
def packageFinished(self, pypack):
for script in self.scripts['package_finished']:
folder = self.config['general']['download_folder']
- folder = save_join(folder, pypack.folder)
+ folder = safe_join(folder, pypack.folder)
self.callScript(script, pypack.name, folder, pypack.password, pypack.id)
@@ -104,14 +104,17 @@ class ExternalScripts(Hook):
for script in self.scripts['after_reconnect']:
self.callScript(script, ip)
- def unrarFinished(self, folder, fname):
- for script in self.scripts["unrar_finished"]:
+ @AddEventListener("extracting:finished")
+ def extractingFinished(self, folder, fname):
+ for script in self.scripts["extracting_finished"]:
self.callScript(script, folder, fname)
+ @AddEventListener("download:allFinished")
def allDownloadsFinished(self):
for script in self.scripts["all_dls_finished"]:
self.callScript(script)
+ @AddEventListener("download:allProcessed")
def allDownloadsProcessed(self):
for script in self.scripts["all_dls_processed"]:
self.callScript(script)
diff --git a/pyload/plugins/addons/ExtractArchive.py b/pyload/plugins/addons/ExtractArchive.py
index 62c947f88..9a66f13c7 100644
--- a/pyload/plugins/addons/ExtractArchive.py
+++ b/pyload/plugins/addons/ExtractArchive.py
@@ -254,7 +254,7 @@ class ExtractArchive(Addon):
self.logDebug("%s does not exists" % f)
self.logInfo(basename(plugin.file), _("Extracting finished"))
- self.manager.dispatchEvent("unrarFinished", plugin.out, plugin.file)
+ self.manager.dispatchEvent("extracting:finished", plugin.out, plugin.file)
return plugin.getExtractedFiles()