diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-10 14:50:24 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-10 14:50:24 +0200 |
commit | c12cb8adcc0eef5ffc11762d85cae9f5ff8c2921 (patch) | |
tree | 3d2b5a37c18414714f68e721b52ca393dd7e75a9 /pyload/plugin | |
parent | [README] Update (2) (diff) | |
parent | added: configdata of deleted or outdated plugins are deletedfrom config (diff) | |
download | pyload-c12cb8adcc0eef5ffc11762d85cae9f5ff8c2921.tar.xz |
Merge pull request #2 from ardi69/0.4.10
makes the plugins runable
Diffstat (limited to 'pyload/plugin')
-rw-r--r-- | pyload/plugin/Account.py | 6 | ||||
-rw-r--r-- | pyload/plugin/Addon.py | 8 | ||||
-rw-r--r-- | pyload/plugin/OCR.py | 6 | ||||
-rw-r--r-- | pyload/plugin/Plugin.py | 43 | ||||
-rw-r--r-- | pyload/plugin/account/OboomCom.py | 14 | ||||
-rw-r--r-- | pyload/plugin/account/SmoozedCom.py | 14 | ||||
-rw-r--r-- | pyload/plugin/addon/ClickAndLoad.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/DeleteFinished.py | 2 | ||||
-rw-r--r-- | pyload/plugin/addon/ExtractArchive.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/MergeFiles.py | 2 | ||||
-rw-r--r-- | pyload/plugin/addon/RestartFailed.py | 2 | ||||
-rw-r--r-- | pyload/plugin/addon/UpdateManager.py | 8 | ||||
-rw-r--r-- | pyload/plugin/hook/XFileSharingPro.py | 2 | ||||
-rw-r--r-- | pyload/plugin/hoster/OverLoadMe.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/MultiHook.py | 10 | ||||
-rw-r--r-- | pyload/plugin/internal/MultiHoster.py | 4 | ||||
-rw-r--r-- | pyload/plugin/internal/SimpleHoster.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/XFSCrypter.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/XFSHoster.py | 2 |
19 files changed, 83 insertions, 54 deletions
diff --git a/pyload/plugin/Account.py b/pyload/plugin/Account.py index b14615d3a..6a3eddc5b 100644 --- a/pyload/plugin/Account.py +++ b/pyload/plugin/Account.py @@ -197,7 +197,7 @@ class Account(Base): "maxtraffic" : None, "premium" : None, "timestamp" : 0, #: time this info was retrieved - "type" : self.__name} + "type" : self.__class__.__name__} def getAllAccounts(self, force=False): @@ -210,7 +210,7 @@ class Account(Base): if not user: return None - req = self.core.requestFactory.getRequest(self.__name, user) + req = self.core.requestFactory.getRequest(self.__class__.__name__, user) return req @@ -220,7 +220,7 @@ class Account(Base): if not user: return None - cj = self.core.requestFactory.getCookieJar(self.__name, user) + cj = self.core.requestFactory.getCookieJar(self.__class__.__name__, user) return cj diff --git a/pyload/plugin/Addon.py b/pyload/plugin/Addon.py index 14b5ee2a5..1f4730851 100644 --- a/pyload/plugin/Addon.py +++ b/pyload/plugin/Addon.py @@ -78,7 +78,7 @@ class Addon(Base): def initPeriodical(self, delay=0, threaded=False): - self.cb = self.core.scheduler.addJob(max(0, delay), self._periodical, args=[threaded], threaded=threaded) + self.cb = self.core.scheduler.addJob(max(0, delay), self._periodical, [threaded], threaded=threaded) def _periodical(self, threaded): @@ -94,11 +94,11 @@ class Addon(Base): if self.core.debug: print_exc() - self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=threaded) + self.cb = self.core.scheduler.addJob(self.interval, self._periodical, [threaded], threaded=threaded) def __repr__(self): - return "<Addon %s>" % self.__name + return "<Addon %s>" % self.__class__.__name__ def setup(self): @@ -117,7 +117,7 @@ class Addon(Base): def isActivated(self): """ checks if addon is activated""" - return self.core.config.getPlugin(self.__name, "activated") + return self.getConfig("activated") # Event methods - overwrite these if needed diff --git a/pyload/plugin/OCR.py b/pyload/plugin/OCR.py index 109dd1843..01ba6d534 100644 --- a/pyload/plugin/OCR.py +++ b/pyload/plugin/OCR.py @@ -60,11 +60,11 @@ class OCR(Base): def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True): #tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") try: - tmpTif = open(fs_join("tmp", "tmpTif_%s.tif" % self.__name), "wb") + tmpTif = open(fs_join("tmp", "tmpTif_%s.tif" % self.__class__.__name__), "wb") tmpTif.close() #tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt") - tmpTxt = open(fs_join("tmp", "tmpTxt_%s.txt" % self.__name), "wb") + tmpTxt = open(fs_join("tmp", "tmpTxt_%s.txt" % self.__class__.__name__), "wb") tmpTxt.close() except IOError, e: @@ -83,7 +83,7 @@ class OCR(Base): if subset and (digits or lowercase or uppercase): #tmpSub = tempfile.NamedTemporaryFile(suffix=".subset") - with open(fs_join("tmp", "tmpSub_%s.subset" % self.__name), "wb") as tmpSub: + with open(fs_join("tmp", "tmpSub_%s.subset" % self.__class__.__name__), "wb") as tmpSub: tmpSub.write("tessedit_char_whitelist ") if digits: diff --git a/pyload/plugin/Plugin.py b/pyload/plugin/Plugin.py index e136bfc29..486dbeb0f 100644 --- a/pyload/plugin/Plugin.py +++ b/pyload/plugin/Plugin.py @@ -6,6 +6,7 @@ from time import time, sleep from random import randint import os +import re from os import remove, makedirs, chmod, stat from os.path import exists, join @@ -18,7 +19,7 @@ from itertools import islice from traceback import print_exc from urlparse import urlparse -from pyload.utils import fs_decode, fs_encode, safe_filename, fs_join +from pyload.utils import fs_decode, fs_encode, safe_filename, fs_join, encode def chunks(iterable, size): @@ -62,7 +63,7 @@ class Base(object): def _log(self, type, args): msg = " | ".join([encode(a).strip() for a in args if a]) logger = getattr(self.core.log, type) - logger("%s: %s" % (self.__name, msg or _("%s MARK" % type.upper()))) + logger("%s: %s" % (self.__class__.__name__, msg or _("%s MARK" % type.upper()))) def logDebug(self, *args): @@ -86,6 +87,10 @@ class Base(object): return self._log("critical", args) + def getPluginConfSection(self): + return "%s_%s" % (self.__class__.__name__, getattr(self, "_%s__type" % self.__class__.__name__)) + + #: Deprecated method def setConf(self, option, value): """ see `setConfig` """ @@ -99,7 +104,7 @@ class Base(object): :param value: :return: """ - self.core.config.setPlugin(self.__name, option, value) + self.core.config.setPlugin(self.getPluginConfSection(), option, value) #: Deprecated method @@ -114,24 +119,24 @@ class Base(object): :param option: :return: """ - return self.core.config.getPlugin(self.__name, option) + return self.core.config.getPlugin(self.getPluginConfSection(), option) def setStorage(self, key, value): """ Saves a value persistently to the database """ - self.core.db.setStorage(self.__name, key, value) + self.core.db.setStorage(self.getPluginConfSection(), key, value) def store(self, key, value): """ same as `setStorage` """ - self.core.db.setStorage(self.__name, key, value) + self.core.db.setStorage(self.getPluginConfSection(), key, value) def getStorage(self, key=None, default=None): """ Retrieves saved value or dict of all saved entries if key is None """ if key: - return self.core.db.getStorage(self.__name, key) or default - return self.core.db.getStorage(self.__name, key) + return self.core.db.getStorage(self.getPluginConfSection(), key) or default + return self.core.db.getStorage(self.getPluginConfSection(), key) def retrieve(self, *args, **kwargs): @@ -141,7 +146,7 @@ class Base(object): def delStorage(self, key): """ Delete entry in db """ - self.core.db.delStorage(self.__name, key) + self.core.db.delStorage(self.__class__.__name__, key) class Plugin(Base): @@ -188,7 +193,7 @@ class Plugin(Base): self.ocr = None #: account handler instance, see :py:class:`Account` - self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__name) + self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__class__.__name__) #: premium status self.premium = False @@ -209,7 +214,7 @@ class Plugin(Base): #: premium status self.premium = self.account.isPremium(self.user) else: - self.req = pyfile.m.core.requestFactory.getRequest(self.__name) + self.req = pyfile.m.core.requestFactory.getRequest(self.__class__.__name__) #: associated pyfile instance, see `PyFile` self.pyfile = pyfile @@ -240,7 +245,7 @@ class Plugin(Base): def __call__(self): - return self.__name + return self.__class__.__name__ def init(self): @@ -277,7 +282,7 @@ class Plugin(Base): def resetAccount(self): """ dont use account and retry download """ self.account = None - self.req = self.core.requestFactory.getRequest(self.__name) + self.req = self.core.requestFactory.getRequest(self.__class__.__name__) self.retry() @@ -451,13 +456,13 @@ class Plugin(Base): id = ("%.2f" % time())[-6:].replace(".", "") - with open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.__name, id, imgtype)), "wb") as tmpCaptcha: + with open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.__class__.__name__, id, imgtype)), "wb") as tmpCaptcha: tmpCaptcha.write(img) - has_plugin = self.__name in self.core.pluginManager.ocrPlugins + has_plugin = self.__class__.__name__ in self.core.pluginManager.ocrPlugins if self.core.captcha: - Ocr = self.core.pluginManager.loadClass("ocr", self.__name) + Ocr = self.core.pluginManager.loadClass("ocr", self.__class__.__name__) else: Ocr = None @@ -535,10 +540,10 @@ class Plugin(Base): from inspect import currentframe frame = currentframe() - framefile = fs_join("tmp", self.__name, "%s_line%s.dump.html" % (frame.f_back.f_code.co_name, frame.f_back.f_lineno)) + framefile = fs_join("tmp", self.__class__.__name__, "%s_line%s.dump.html" % (frame.f_back.f_code.co_name, frame.f_back.f_lineno)) try: - if not exists(join("tmp", self.__name)): - makedirs(join("tmp", self.__name)) + if not exists(join("tmp", self.__class__.__name__)): + makedirs(join("tmp", self.__class__.__name__)) with open(framefile, "wb") as f: del frame #: delete the frame or it wont be cleaned diff --git a/pyload/plugin/account/OboomCom.py b/pyload/plugin/account/OboomCom.py index 7b73c38fa..0712cbc37 100644 --- a/pyload/plugin/account/OboomCom.py +++ b/pyload/plugin/account/OboomCom.py @@ -2,7 +2,19 @@ import time -from beaker.crypto.pbkdf2 import PBKDF2 +try: + from beaker.crypto.pbkdf2 import PBKDF2 +except: + from beaker.crypto.pbkdf2 import pbkdf2 + from binascii import b2a_hex + class PBKDF2(object): + def __init__(self, passphrase, salt, iterations=1000): + self.passphrase = passphrase + self.salt = salt + self.iterations = iterations + + def hexread(self, octets): + return b2a_hex(pbkdf2(self.passphrase, self.salt, self.iterations, octets)) from pyload.utils import json_loads from pyload.plugin.Account import Account diff --git a/pyload/plugin/account/SmoozedCom.py b/pyload/plugin/account/SmoozedCom.py index 54cd94fbf..ffe7142cf 100644 --- a/pyload/plugin/account/SmoozedCom.py +++ b/pyload/plugin/account/SmoozedCom.py @@ -3,7 +3,19 @@ import hashlib import time -from beaker.crypto.pbkdf2 import PBKDF2 +try: + from beaker.crypto.pbkdf2 import PBKDF2 +except: + from beaker.crypto.pbkdf2 import pbkdf2 + from binascii import b2a_hex + class PBKDF2(object): + def __init__(self, passphrase, salt, iterations=1000): + self.passphrase = passphrase + self.salt = salt + self.iterations = iterations + + def hexread(self, octets): + return b2a_hex(pbkdf2(self.passphrase, self.salt, self.iterations, octets)) from pyload.utils import json_loads from pyload.plugin.Account import Account diff --git a/pyload/plugin/addon/ClickAndLoad.py b/pyload/plugin/addon/ClickAndLoad.py index 708f7da0b..1e420fa8e 100644 --- a/pyload/plugin/addon/ClickAndLoad.py +++ b/pyload/plugin/addon/ClickAndLoad.py @@ -37,11 +37,11 @@ class ClickAndLoad(Addon): def activate(self): - if not self.config['webinterface']['activated']: + if not self.core.config['webui']['activated']: return ip = "" if self.getConfig('extern') else "127.0.0.1" - webport = self.config['webinterface']['port'] + webport = self.core.config['webui']['port'] cnlport = self.getConfig('port') self.proxy(ip, webport, cnlport) diff --git a/pyload/plugin/addon/DeleteFinished.py b/pyload/plugin/addon/DeleteFinished.py index 2349503f6..7e47a8728 100644 --- a/pyload/plugin/addon/DeleteFinished.py +++ b/pyload/plugin/addon/DeleteFinished.py @@ -52,7 +52,7 @@ class DeleteFinished(Addon): def activate(self): self.info['sleep'] = True # interval = self.getConfig('interval') - # self.pluginConfigChanged(self.__name, 'interval', interval) + # self.pluginConfigChanged(self.__class__.__name__, 'interval', interval) self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60 * 60) self.addEvent('packageFinished', self.wakeup) self.initPeriodical() diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py index 369be11bb..c5b3b6993 100644 --- a/pyload/plugin/addon/ExtractArchive.py +++ b/pyload/plugin/addon/ExtractArchive.py @@ -173,7 +173,7 @@ class ExtractArchive(Addon): print_exc() if self.extractors: - self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name,Extractor.VERSION) for Extractor in self.extractors)) + self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__,Extractor.VERSION) for Extractor in self.extractors)) self.extractQueued() #: Resume unfinished extractions else: self.logInfo(_("No Extract plugins activated")) @@ -288,7 +288,7 @@ class ExtractArchive(Addon): for Extractor in self.extractors: targets = Extractor.getTargets(files_ids) if targets: - self.logDebug("Targets for %s: %s" % (Extractor.__name, targets)) + self.logDebug("Targets for %s: %s" % (Extractor.__class__.__name__, targets)) matched = True for fname, fid, fout in targets: diff --git a/pyload/plugin/addon/MergeFiles.py b/pyload/plugin/addon/MergeFiles.py index 87775bea2..a0298052b 100644 --- a/pyload/plugin/addon/MergeFiles.py +++ b/pyload/plugin/addon/MergeFiles.py @@ -46,7 +46,7 @@ class MergeFiles(Addon): for name, file_list in files.iteritems(): self.logInfo(_("Starting merging of"), name) - final_file = open(fs_join(download_folder, name), "wb") + with open(fs_join(download_folder, name), "wb") as final_file: for splitted_file in file_list: self.logDebug("Merging part", splitted_file) diff --git a/pyload/plugin/addon/RestartFailed.py b/pyload/plugin/addon/RestartFailed.py index eaa86ebcb..695ebb154 100644 --- a/pyload/plugin/addon/RestartFailed.py +++ b/pyload/plugin/addon/RestartFailed.py @@ -38,6 +38,6 @@ class RestartFailed(Addon): def activate(self): - # self.pluginConfigChanged(self.__name, "interval", self.getConfig('interval')) + # self.pluginConfigChanged(self.__class__.__name__, "interval", self.getConfig('interval')) self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60) self.initPeriodical() diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py index a2b26b618..41a1d7f2c 100644 --- a/pyload/plugin/addon/UpdateManager.py +++ b/pyload/plugin/addon/UpdateManager.py @@ -83,15 +83,15 @@ class UpdateManager(Addon): def autoreloadPlugins(self): """ reload and reindex all modified plugins """ modules = filter( - lambda m: m and (m.__name.startswith("module.plugins.") or - m.__name.startswith("userplugins.")) and - m.__name.count(".") >= 2, sys.modules.itervalues() + lambda m: m and (m.__name__.startswith("module.plugins.") or + m.__name__.startswith("userplugins.")) and + m.__name__.count(".") >= 2, sys.modules.itervalues() ) reloads = [] for m in modules: - root, type, name = m.__name.rsplit(".", 2) + root, type, name = m.__name__.rsplit(".", 2) id = (type, name) if type in self.core.pluginManager.plugins: f = m.__file__.replace(".pyc", ".py") diff --git a/pyload/plugin/hook/XFileSharingPro.py b/pyload/plugin/hook/XFileSharingPro.py index 9ded9cd53..1f3a27fd5 100644 --- a/pyload/plugin/hook/XFileSharingPro.py +++ b/pyload/plugin/hook/XFileSharingPro.py @@ -50,7 +50,7 @@ class XFileSharingPro(Hook): def loadPattern(self): - use_builtin_list = self.getConfig('use_builtin_list') + use_builtin_list = self.getConfig("use_builtin_list") for type in ("hoster", "crypter"): every_plugin = not self.getConfig('use_%s_list' % type) diff --git a/pyload/plugin/hoster/OverLoadMe.py b/pyload/plugin/hoster/OverLoadMe.py index ca365549a..ad15f60df 100644 --- a/pyload/plugin/hoster/OverLoadMe.py +++ b/pyload/plugin/hoster/OverLoadMe.py @@ -47,6 +47,6 @@ class OverLoadMe(MultiHoster): pyfile.size = parseFileSize(data['filesize']) http_repl = ["http://", "https://"] - self.link = data['downloadlink'].replace(*http_repl if self.getConfig('ssl') else *http_repl[::-1]) + self.link = data['downloadlink'].replace(*http_repl if self.getConfig('ssl') else http_repl[::-1]) diff --git a/pyload/plugin/internal/MultiHook.py b/pyload/plugin/internal/MultiHook.py index 5e828cd5e..acf17f6dc 100644 --- a/pyload/plugin/internal/MultiHook.py +++ b/pyload/plugin/internal/MultiHook.py @@ -68,16 +68,16 @@ class MultiHook(Hook): def _initPlugin(self): - plugin, type = self.core.pluginManager.findPlugin(self.__name) + plugin = self.core.pluginManager.findPlugin("hoster", self.__class__.__name__) if not plugin: self.logWarning("Hook plugin will be deactivated due missing plugin reference") self.setConfig('activated', False) else: - self.pluginname = self.__name - self.plugintype = type - self.pluginmodule = self.core.pluginManager.loadModule(type, self.__name) - self.pluginclass = getattr(self.pluginmodule, self.__name) + self.pluginname = self.__class__.__name__ + self.plugintype = "hoster" + self.pluginmodule = self.core.pluginManager.loadModule("hoster", self.__class__.__name__) + self.pluginclass = getattr(self.pluginmodule, self.__class__.__name__) def loadAccount(self): diff --git a/pyload/plugin/internal/MultiHoster.py b/pyload/plugin/internal/MultiHoster.py index a38da9bdb..a7e74b2ff 100644 --- a/pyload/plugin/internal/MultiHoster.py +++ b/pyload/plugin/internal/MultiHoster.py @@ -86,8 +86,8 @@ class MultiHoster(SimpleHoster): self.retryFree() elif self.getConfig('revertfailed', True) \ - and "new_module" in self.core.pluginManager.hosterPlugins[self.__name]: - hdict = self.core.pluginManager.hosterPlugins[self.__name] + and "new_module" in self.core.pluginManager.hosterPlugins[self.__class__.__name__]: + hdict = self.core.pluginManager.hosterPlugins[self.__class__.__name__] tmp_module = hdict['new_module'] tmp_name = hdict['new_name'] diff --git a/pyload/plugin/internal/SimpleHoster.py b/pyload/plugin/internal/SimpleHoster.py index d07eca2a1..60f13324f 100644 --- a/pyload/plugin/internal/SimpleHoster.py +++ b/pyload/plugin/internal/SimpleHoster.py @@ -437,7 +437,7 @@ class SimpleHoster(Hoster): set_cookies(self.req.cj, self.COOKIES) if (self.MULTI_HOSTER - and (self.__pattern != self.core.pluginManager.hosterPlugins[self.__name]['pattern'] + and (self.__pattern != self.core.pluginManager.hosterPlugins[self.__class__.__name__]['pattern'] or re.match(self.__pattern, self.pyfile.url) is None)): self.multihost = True return diff --git a/pyload/plugin/internal/XFSCrypter.py b/pyload/plugin/internal/XFSCrypter.py index 44b4ed724..6a3f09e55 100644 --- a/pyload/plugin/internal/XFSCrypter.py +++ b/pyload/plugin/internal/XFSCrypter.py @@ -31,7 +31,7 @@ class XFSCrypter(SimpleCrypter): if self.account: account = self.account else: - account_name = (self.__name + ".py").replace("Folder.py", "").replace(".py", "") + account_name = (self.__class__.__name__ + ".py").replace("Folder.py", "").replace(".py", "") account = self.pyfile.m.core.accountManager.getAccountPlugin(account_name) if account and hasattr(account, "HOSTER_DOMAIN") and account.HOSTER_DOMAIN: diff --git a/pyload/plugin/internal/XFSHoster.py b/pyload/plugin/internal/XFSHoster.py index 05b26bebe..e87b6b0ee 100644 --- a/pyload/plugin/internal/XFSHoster.py +++ b/pyload/plugin/internal/XFSHoster.py @@ -64,7 +64,7 @@ class XFSHoster(SimpleHoster): if self.account: account = self.account else: - account = self.pyfile.m.core.accountManager.getAccountPlugin(self.__name) + account = self.pyfile.m.core.accountManager.getAccountPlugin(self.__class__.__name__) if account and hasattr(account, "HOSTER_DOMAIN") and account.HOSTER_DOMAIN: self.HOSTER_DOMAIN = account.HOSTER_DOMAIN |