From 1340c543e296f41a9a4ab7377f016c50e716535c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 2 Jul 2014 14:29:44 +0200 Subject: [UpdateManager] Fix interval changing procedure --- module/plugins/hooks/UpdateManager.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 9f8ccdb80..8e8449a51 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -14,7 +14,7 @@ from module.plugins.Hook import threaded, Expose, Hook class UpdateManager(Hook): __name__ = "UpdateManager" - __version__ = "0.24" + __version__ = "0.25" __description__ = """Check for updates""" __config__ = [("activated", "bool", "Activated", True), ("mode", "pyLoad + plugins;plugins only", "Check updates for", "pyLoad + plugins"), @@ -25,15 +25,21 @@ class UpdateManager(Hook): __author_mail__ = ("ranan@pyload.org", "l.stickell@yahoo.it", "vuolter@gmail.com") SERVER_URL = "http://updatemanager.pyload.org" - MIN_TIME = 3 * 60 * 60 #: 3h minimum check interval + MIN_TIME = 3 * 60 * 60 #: 3h minimum check interval (seconds) event_list = ["pluginConfigChanged"] def pluginConfigChanged(self, plugin, name, value): - if name == "interval" and 0 < value != self.interval: - self.interval = max(value * 60 * 60, self.MIN_TIME) - self.initPeriodical() + if name == "interval": + interval = value * 60 * 60 + if self.MIN_TIME <= interval != self.interval: + if self.cb: + self.core.scheduler.removeJob(self.cb) + self.interval = interval + self.initPeriodical() + else: + self.logWarning("Invalid interval value, kept current") elif name == "reloadplugins": if self.cb2: self.core.scheduler.removeJob(self.cb2) -- cgit v1.2.3 From 1609d320be17c87ff0c7640511c9ba911fdd862e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 5 Jul 2014 02:24:04 +0200 Subject: Fixed https://github.com/pyload/pyload/issues/671 + improved threading --- module/plugins/hooks/UpdateManager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 8e8449a51..ce06612bd 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -14,7 +14,7 @@ from module.plugins.Hook import threaded, Expose, Hook class UpdateManager(Hook): __name__ = "UpdateManager" - __version__ = "0.25" + __version__ = "0.26" __description__ = """Check for updates""" __config__ = [("activated", "bool", "Activated", True), ("mode", "pyLoad + plugins;plugins only", "Check updates for", "pyLoad + plugins"), @@ -34,8 +34,7 @@ class UpdateManager(Hook): if name == "interval": interval = value * 60 * 60 if self.MIN_TIME <= interval != self.interval: - if self.cb: - self.core.scheduler.removeJob(self.cb) + self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() else: @@ -43,10 +42,11 @@ class UpdateManager(Hook): elif name == "reloadplugins": if self.cb2: self.core.scheduler.removeJob(self.cb2) - if value and self.core.debug: + if value == True and self.core.debug: self.periodical2() def coreReady(self): + self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig("reloadplugins")) def setup(self): @@ -89,7 +89,6 @@ class UpdateManager(Hook): return True if self.core.pluginManager.reloadPlugins(reloads) else False - @threaded def periodical(self): if not self.info["pyload"] and not (self.getConfig("nodebugupdate") and self.core.debug): self.updating = True @@ -108,6 +107,7 @@ class UpdateManager(Hook): return self.update(onlyplugin=True) @Expose + @threaded def update(self, onlyplugin=False): """ check for updates """ data = self.server_response() -- cgit v1.2.3 From 999a67f7e2a18fd3ef93bd0a5429f5c45ed5fb53 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 5 Jul 2014 18:02:02 +0200 Subject: [UpdateManager] Better if-condition check (thx stickell) --- module/plugins/hooks/UpdateManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index ce06612bd..c37f026e3 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -42,7 +42,7 @@ class UpdateManager(Hook): elif name == "reloadplugins": if self.cb2: self.core.scheduler.removeJob(self.cb2) - if value == True and self.core.debug: + if value is True and self.core.debug: self.periodical2() def coreReady(self): -- cgit v1.2.3 From c9c16f69e39580ae7744b05f60268578e6032563 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 5 Jul 2014 22:35:14 +0200 Subject: [RestartFailed] Code cleanup --- module/plugins/hooks/RestartFailed.py | 65 ++++++++++++++++------------------- 1 file changed, 30 insertions(+), 35 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 85553d738..89bbcb19e 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -1,57 +1,52 @@ # -*- coding: utf-8 -*- - -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . - - @author: Walter Purcaro -""" +############################################################################ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +############################################################################ from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" - __version__ = "1.53" + __version__ = "1.54" __description__ = """Periodically restart all failed downloads in queue""" __config__ = [("activated", "bool", "Activated", False), - ("interval", "int", "Interval in minutes", 90)] + ("interval", "int", "Check interval in minutes", 90)] __author_name__ = "Walter Purcaro" __author_mail__ = "vuolter@gmail.com" + MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) + event_list = ["pluginConfigChanged"] - MIN_INTERVAL = 15 * 60 # seconds def periodical(self): - self.logDebug("Restart all failed downloads now") + self.logInfo("Restart failed downloads") self.core.api.restartFailed() - def restartPeriodical(self, interval): - self.logDebug("Set periodical interval to %s seconds" % interval) - if self.cb: - self.core.scheduler.removeJob(self.cb) - self.interval = interval - self.cb = self.core.scheduler.addJob(interval, self._periodical, threaded=False) - def pluginConfigChanged(self, plugin, name, value): - value *= 60 - if name == "interval": - if self.interval != value > self.MIN_INTERVAL: - self.restartPeriodical(value) + if name != "interval": + interval = value * 60 + if self.MIN_INTERVAL <= interval != self.interval: + self.core.scheduler.removeJob(self.cb) + self.interval = interval + self.initPeriodical() else: - self.logWarning("Cannot change interval: given value is equal to the current or \ - smaller than %s seconds" % self.MIN_INTERVAL) + self.logWarning("Invalid interval value, kept current") + + def setup(self): + self.interval = self.MIN_INTERVAL def coreReady(self): - self.pluginConfigChanged(plugin="RestartFailed", name="interval", value=self.getConfig("interval")) + self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) -- cgit v1.2.3 From 4f0ecca2cad57aea6620f713067b465ca34c1a6f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 5 Jul 2014 22:36:50 +0200 Subject: [UpdateManager] Little code cleanup + improved threading --- module/plugins/hooks/UpdateManager.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index c37f026e3..0713cc0b5 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -25,7 +25,7 @@ class UpdateManager(Hook): __author_mail__ = ("ranan@pyload.org", "l.stickell@yahoo.it", "vuolter@gmail.com") SERVER_URL = "http://updatemanager.pyload.org" - MIN_TIME = 3 * 60 * 60 #: 3h minimum check interval (seconds) + MIN_INTERVAL = 3 * 60 * 60 #: 3h minimum check interval (value is in seconds) event_list = ["pluginConfigChanged"] @@ -33,7 +33,7 @@ class UpdateManager(Hook): def pluginConfigChanged(self, plugin, name, value): if name == "interval": interval = value * 60 * 60 - if self.MIN_TIME <= interval != self.interval: + if self.MIN_INTERVAL <= interval != self.interval: self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() @@ -51,7 +51,7 @@ class UpdateManager(Hook): def setup(self): self.cb2 = None - self.interval = self.MIN_TIME + self.interval = self.MIN_INTERVAL self.updating = False self.info = {"pyload": False, "version": None, "plugins": False} self.mtimes = {} #: store modification time for each plugin @@ -107,7 +107,6 @@ class UpdateManager(Hook): return self.update(onlyplugin=True) @Expose - @threaded def update(self, onlyplugin=False): """ check for updates """ data = self.server_response() @@ -127,6 +126,7 @@ class UpdateManager(Hook): self.info["version"] = newversion return r + @threaded def _updatePlugins(self, updates): """ check for plugin updates """ -- cgit v1.2.3 From aba96db5e5864703e834a035f524df7405dbe389 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 6 Jul 2014 19:00:03 +0200 Subject: Remove two dead plugins --- module/plugins/hooks/ReloadCc.py | 67 ----------------------------- module/plugins/hooks/Vipleech4uCom.py | 80 ----------------------------------- 2 files changed, 147 deletions(-) delete mode 100644 module/plugins/hooks/ReloadCc.py delete mode 100644 module/plugins/hooks/Vipleech4uCom.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ReloadCc.py b/module/plugins/hooks/ReloadCc.py deleted file mode 100644 index 9960a2699..000000000 --- a/module/plugins/hooks/ReloadCc.py +++ /dev/null @@ -1,67 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHoster import MultiHoster - -from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL - - -class ReloadCc(MultiHoster): - __name__ = "ReloadCc" - __version__ = "0.3" - __type__ = "hook" - __description__ = """Reload.cc hook plugin""" - - __config__ = [("activated", "bool", "Activated", False), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("hosterList", "str", "Hoster list (comma separated)", "")] - - __author_name__ = "Reload Team" - __author_mail__ = "hello@reload.cc" - - interval = 0 # Disable periodic calls - - def getHoster(self): - # If no accounts are available there will be no hosters available - if not self.account or not self.account.canUse(): - print "ReloadCc: No accounts available" - return [] - - # Get account data - (user, data) = self.account.selectAccount() - - # Get supported hosters list from reload.cc using the json API v1 - query_params = dict( - via='pyload', - v=1, - get_supported='true', - get_traffic='true', - user=user - ) - - try: - query_params.update(dict(hash=self.account.infos[user]['pwdhash'])) - except Exception: - query_params.update(dict(pwd=data['password'])) - - answer = getURL("http://api.reload.cc/login", get=query_params) - data = json_loads(answer) - - # If account is not valid thera are no hosters available - if data['status'] != "ok": - print "ReloadCc: Status is not ok: %s" % data['status'] - return [] - - # Extract hosters from json file - return data['msg']['supportedHosters'] - - def coreReady(self): - # Get account plugin and check if there is a valid account available - self.account = self.core.accountManager.getAccountPlugin("ReloadCc") - if not self.account.canUse(): - self.account = None - self.logError("Please add a valid reload.cc account first and restart pyLoad.") - return - - # Run the overwriten core ready which actually enables the multihoster hook - return MultiHoster.coreReady(self) diff --git a/module/plugins/hooks/Vipleech4uCom.py b/module/plugins/hooks/Vipleech4uCom.py deleted file mode 100644 index b2156b017..000000000 --- a/module/plugins/hooks/Vipleech4uCom.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -import re - -from module.network.RequestFactory import getURL -from module.plugins.internal.MultiHoster import MultiHoster - - -class Vipleech4uCom(MultiHoster): - __name__ = "Vipleech4uCom" - __version__ = "0.01" - __type__ = "hook" - __config__ = [("activated", "bool", "Activated", "False"), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", "")] - __description__ = """Vipleech4u.com hook plugin""" - __author_name__ = ("Kagenoshin") - __author_mail__ = ("kagenoshin@gmx.ch") - - HOSTER_PATTERN = re.compile(r'align\s*?=\s*?["\']*?left.*?<\s*?strong\s*?>([^<]*?)<', re.I) - - def getHoster(self): - hosters = { - 'depositfiles': ['depositfiles.com', 'dfiles.eu'], - 'uploaded': ['uploaded.to', 'uploaded.net', 'ul.to'], - 'rapidggator': ['rapidgator.net'], # they have a typo it's called rapidgator - 'freakshare': ['freakshare.net', 'freakshare.com'], - 'filefactory': ['filefactory.com'], - 'bitshare': ['bitshare.com'], - 'share-online': ['share-online.biz', 'egoshare.com'], - 'youtube': ['youtube.com'], - 'turbobit': ['turbobit.net', 'unextfiles.com'], - 'firedrive': ['firedrive.com', 'putlocker.com'], - 'filepost': ['filepost.com', 'fp.io'], - 'netload': ['netload.in'], - 'uploadhero': ['uploadhero.com'], - 'ryushare': ['ryushare.com'], - } - - #check if the list is still valid - self.check_for_new_or_removed_hosters(hosters) - - #build list - hoster_list = [] - - for item in hosters.itervalues(): - hoster_list.extend(item) - - return hoster_list - - def check_for_new_or_removed_hosters(self, hosters): - #get the old hosters - old_hosters = hosters.keys() - - #load the current hosters from vipleech4u.com - page = getURL('http://vipleech4u.com/hosts.php') - current_hosters = self.HOSTER_PATTERN.findall(page) - current_hosters = [x.lower() for x in current_hosters] - - #let's look for new hosters - new_hosters = [] - - for hoster in current_hosters: - if not hoster in old_hosters: - new_hosters.append(hoster) - - #let's look for removed hosters - removed_hosters = [] - - for hoster in old_hosters: - if not hoster in current_hosters: - removed_hosters.append(hoster) - - if new_hosters: - self.logDebug('The following new hosters were found on vipleech4u.com: %s' % str(new_hosters)) - - if removed_hosters: - self.logDebug('The following hosters were removed from vipleech4u.com: %s' % str(removed_hosters)) - - if not (new_hosters and removed_hosters): - self.logDebug('The hoster list is still valid.') -- cgit v1.2.3 From 4778a7ed4fa4750ecd6edf1caa48f9716fe0997e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 7 Jul 2014 15:14:08 +0200 Subject: [UpdateManager] Fixed broken updating for new plugin + sort updates + better exception handling + improved update speed performance --- module/plugins/hooks/UpdateManager.py | 89 ++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 43 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 0713cc0b5..ceb229758 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -3,26 +3,26 @@ import sys import re +from operator import itemgetter from os import remove, stat from os.path import join, isfile from time import time -from module.ConfigParser import IGNORE from module.network.RequestFactory import getURL from module.plugins.Hook import threaded, Expose, Hook class UpdateManager(Hook): __name__ = "UpdateManager" - __version__ = "0.26" + __version__ = "0.30" __description__ = """Check for updates""" __config__ = [("activated", "bool", "Activated", True), ("mode", "pyLoad + plugins;plugins only", "Check updates for", "pyLoad + plugins"), ("interval", "int", "Check interval in hours", 8), ("reloadplugins", "bool", "Monitor plugins for code changes (debug mode only)", True), ("nodebugupdate", "bool", "Don't check for updates in debug mode", True)] - __author_name__ = ("RaNaN", "stickell", "Walter Purcaro") - __author_mail__ = ("ranan@pyload.org", "l.stickell@yahoo.it", "vuolter@gmail.com") + __author_name__ = "Walter Purcaro" + __author_mail__ = "vuolter@gmail.com" SERVER_URL = "http://updatemanager.pyload.org" MIN_INTERVAL = 3 * 60 * 60 #: 3h minimum check interval (value is in seconds) @@ -38,7 +38,7 @@ class UpdateManager(Hook): self.interval = interval self.initPeriodical() else: - self.logWarning("Invalid interval value, kept current") + self.logDebug("Invalid interval value, kept current") elif name == "reloadplugins": if self.cb2: self.core.scheduler.removeJob(self.cb2) @@ -66,8 +66,9 @@ class UpdateManager(Hook): 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 = [] @@ -137,19 +138,19 @@ class UpdateManager(Hook): vre = re.compile(r'__version__.*=.*("|\')([0-9.]+)') url = updates[0] - schema = updates[1].split("|") - if 'BLACKLIST' in updates: + schema = updates[1].split('|') + if "BLACKLIST" in updates: blacklist = updates[updates.index('BLACKLIST') + 1:] updates = updates[2:updates.index('BLACKLIST')] else: blacklist = None updates = updates[2:] - for plugin in updates: - info = dict(zip(schema, plugin.split("|"))) - filename = info["name"] - prefix = info["type"] - version = info["version"] + data = sorted(map(lambda x: dict(zip(schema, x.split('|'))), updates), key=itemgetter("type", "name")) + for plugin in data: + filename = plugin["name"] + prefix = plugin["type"] + version = plugin["version"] if filename.endswith(".pyc"): name = filename[:filename.find("_")] @@ -164,37 +165,35 @@ class UpdateManager(Hook): plugins = getattr(self.core.pluginManager, "%sPlugins" % type) - if name not in plugins or name in IGNORE or (type, name) in IGNORE: - continue - - oldver = float(plugins[name]["v"]) + oldver = float(plugins[name]["v"]) if name in plugins else None newver = float(version) - if oldver >= newver: - continue + if not oldver: + msg = "New version of [%(type)s] %(name)s (v%(newver)s)" + elif newver > oldver: + msg = "New version of [%(type)s] %(name)s (v%(oldver)s -> v%(newver)s)" else: - self.logInfo(_("New version of [%(type)s] %(name)s (v%(oldver)s -> v%(newver)s)") % { - "type": type, - "name": name, - "oldver": oldver, - "newver": newver - }) + continue + + self.logInfo(_(msg) % { + "type": type, + "name": name, + "oldver": oldver, + "newver": newver + }) try: - content = getURL(url % info) + content = getURL(url % plugin) + m = vre.search(content) + if m and m.group(2) == version: + f = open(join("userplugins", prefix, filename), "wb") + f.write(content) + f.close() + updated.append((prefix, name)) + else: + raise Exception(_("Version mismatch")) except Exception, e: self.logError(_("Error when updating plugin %s") % filename, str(e)) - continue - - m = vre.search(content) - if not m or m.group(2) != version: - self.logError(_("Error when updating plugin %s") % name, _("Version mismatch")) - continue - - f = open(join("userplugins", prefix, filename), "wb") - f.write(content) - f.close() - updated.append((prefix, name)) if blacklist: removed = self.removePlugins(map(lambda x: x.split('|'), blacklist)) @@ -230,11 +229,15 @@ class UpdateManager(Hook): for type, name in type_plugins: py = join("userplugins", type, name) pyc = join("userplugins", type, name.replace('.py', '.pyc')) - if isfile(py): - id = (type, name) - remove(py) + id = (type, name) + try: + if isfile(py): + remove(py) + if isfile(pyc): + remove(pyc) + except Exception, e: + self.logError("Error when deleting %s" % id, str(e)) + else: removed.append(id) - if isfile(pyc): - remove(pyc) return removed #: return a list of the plugins successfully removed -- cgit v1.2.3 From cec2250f13753ea37312a56871cd6acf8d1d09dc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 7 Jul 2014 18:48:27 +0200 Subject: [RestartFailed] Fixed bad interval checking --- module/plugins/hooks/RestartFailed.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 89bbcb19e..3ee2aeed4 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################ +############################################################################### # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the @@ -12,14 +12,14 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -############################################################################ +############################################################################### from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" - __version__ = "1.54" + __version__ = "1.55" __description__ = """Periodically restart all failed downloads in queue""" __config__ = [("activated", "bool", "Activated", False), ("interval", "int", "Check interval in minutes", 90)] @@ -31,21 +31,22 @@ class RestartFailed(Hook): event_list = ["pluginConfigChanged"] - def periodical(self): - self.logInfo("Restart failed downloads") - self.core.api.restartFailed() - def pluginConfigChanged(self, plugin, name, value): - if name != "interval": + if name == "interval": interval = value * 60 if self.MIN_INTERVAL <= interval != self.interval: self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() else: - self.logWarning("Invalid interval value, kept current") + self.logDebug("Invalid interval value, kept current") + + def periodical(self): + self.logInfo("Restart failed downloads") + self.api.restartFailed() def setup(self): + self.api = self.core.api self.interval = self.MIN_INTERVAL def coreReady(self): -- cgit v1.2.3 From 0eaca8de20629dd115d1d1f7bf02b26e787ff10d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 7 Jul 2014 18:50:40 +0200 Subject: [UpdateManager] Improve code a bit more again --- module/plugins/hooks/UpdateManager.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index ceb229758..04e5a8698 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -9,7 +9,7 @@ from os.path import join, isfile from time import time from module.network.RequestFactory import getURL -from module.plugins.Hook import threaded, Expose, Hook +from module.plugins.Hook import Expose, Hook, threaded class UpdateManager(Hook): @@ -34,14 +34,14 @@ class UpdateManager(Hook): if name == "interval": interval = value * 60 * 60 if self.MIN_INTERVAL <= interval != self.interval: - self.core.scheduler.removeJob(self.cb) + self.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() else: self.logDebug("Invalid interval value, kept current") elif name == "reloadplugins": if self.cb2: - self.core.scheduler.removeJob(self.cb2) + self.scheduler.removeJob(self.cb2) if value is True and self.core.debug: self.periodical2() @@ -50,6 +50,7 @@ class UpdateManager(Hook): self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig("reloadplugins")) def setup(self): + self.scheduler = self.core.scheduler self.cb2 = None self.interval = self.MIN_INTERVAL self.updating = False @@ -60,7 +61,7 @@ class UpdateManager(Hook): def periodical2(self): if not self.updating: self.autoreloadPlugins() - self.cb2 = self.core.scheduler.addJob(10, self.periodical2, threaded=True) + self.cb2 = self.scheduler.addJob(10, self.periodical2, threaded=True) @Expose def autoreloadPlugins(self): @@ -210,7 +211,7 @@ class UpdateManager(Hook): else: self.logInfo(_("*** Plugins have been updated, pyLoad will be restarted now ***")) self.info["plugins"] = True - self.core.scheduler.addJob(4, self.core.api.restart(), threaded=False) #: risky, but pyload doesn't let more + self.scheduler.addJob(4, self.core.api.restart(), threaded=False) #: risky, but pyload doesn't let more return True else: self.logInfo(_("No plugin updates available")) -- cgit v1.2.3 From 85d58360d2adb7f4405a5b8351377a82c4d7ee7d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 13 Jul 2014 22:19:28 +0200 Subject: [CaptchaTrader] Removed because service is dead --- module/plugins/hooks/CaptchaTrader.py | 157 ---------------------------------- 1 file changed, 157 deletions(-) delete mode 100644 module/plugins/hooks/CaptchaTrader.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/CaptchaTrader.py b/module/plugins/hooks/CaptchaTrader.py deleted file mode 100644 index 051dc6c2b..000000000 --- a/module/plugins/hooks/CaptchaTrader.py +++ /dev/null @@ -1,157 +0,0 @@ -# -*- coding: utf-8 -*- - -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . - - @author: mkaay, RaNaN -""" - -from thread import start_new_thread -from pycurl import FORM_FILE, LOW_SPEED_TIME - -from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL, getRequest -from module.network.HTTPRequest import BadHeader -from module.plugins.Hook import Hook - -PYLOAD_KEY = "9f65e7f381c3af2b076ea680ae96b0b7" - - -class CaptchaTraderException(Exception): - def __init__(self, err): - self.err = err - - def getCode(self): - return self.err - - def __str__(self): - return "" % self.err - - def __repr__(self): - return "" % self.err - - -class CaptchaTrader(Hook): - __name__ = "CaptchaTrader" - __version__ = "0.16" - __description__ = """Send captchas to captchatrader.com""" - __config__ = [("activated", "bool", "Activated", False), - ("username", "str", "Username", ""), - ("force", "bool", "Force CT even if client is connected", False), - ("passkey", "password", "Password", "")] - __author_name__ = "RaNaN" - __author_mail__ = "RaNaN@pyload.org" - - SUBMIT_URL = "http://api.captchatrader.com/submit" - RESPOND_URL = "http://api.captchatrader.com/respond" - GETCREDITS_URL = "http://api.captchatrader.com/get_credits/username:%(user)s/password:%(password)s/" - - def setup(self): - self.info = {} - - def getCredits(self): - json = getURL(CaptchaTrader.GETCREDITS_URL % {"user": self.getConfig("username"), - "password": self.getConfig("passkey")}) - response = json_loads(json) - if response[0] < 0: - raise CaptchaTraderException(response[1]) - else: - self.logInfo(_("%s credits left") % response[1]) - self.info["credits"] = response[1] - return response[1] - - def submit(self, captcha, captchaType="file", match=None): - if not PYLOAD_KEY: - raise CaptchaTraderException("No API Key Specified!") - - #if type(captcha) == str and captchaType == "file": - # raise CaptchaTraderException("Invalid Type") - assert captchaType in ("file", "url-jpg", "url-jpeg", "url-png", "url-bmp") - - req = getRequest() - - #raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) - - try: - json = req.load(CaptchaTrader.SUBMIT_URL, post={"api_key": PYLOAD_KEY, - "username": self.getConfig("username"), - "password": self.getConfig("passkey"), - "value": (FORM_FILE, captcha), - "type": captchaType}, multipart=True) - finally: - req.close() - - response = json_loads(json) - if response[0] < 0: - raise CaptchaTraderException(response[1]) - - ticket = response[0] - result = response[1] - self.logDebug("result %s : %s" % (ticket, result)) - - return ticket, result - - def respond(self, ticket, success): - try: - json = getURL(CaptchaTrader.RESPOND_URL, post={"is_correct": 1 if success else 0, - "username": self.getConfig("username"), - "password": self.getConfig("passkey"), - "ticket": ticket}) - - response = json_loads(json) - if response[0] < 0: - raise CaptchaTraderException(response[1]) - - except BadHeader, e: - self.logError(_("Could not send response."), str(e)) - - def newCaptchaTask(self, task): - if not task.isTextual(): - return False - - if not self.getConfig("username") or not self.getConfig("passkey"): - return False - - if self.core.isClientConnected() and not self.getConfig("force"): - return False - - if self.getCredits() > 10: - task.handler.append(self) - task.setWaiting(100) - start_new_thread(self.processCaptcha, (task,)) - - else: - self.logInfo(_("Your CaptchaTrader Account has not enough credits")) - - def captchaCorrect(self, task): - if "ticket" in task.data: - ticket = task.data["ticket"] - self.respond(ticket, True) - - def captchaInvalid(self, task): - if "ticket" in task.data: - ticket = task.data["ticket"] - self.respond(ticket, False) - - def processCaptcha(self, task): - c = task.captchaFile - try: - ticket, result = self.submit(c) - except CaptchaTraderException, e: - task.error = e.getCode() - return - - task.data["ticket"] = ticket - task.setResult(result) -- cgit v1.2.3 From 4811058490989e5150fd57ea8f0afedddba98069 Mon Sep 17 00:00:00 2001 From: Stefano Date: Mon, 14 Jul 2014 21:05:08 +0200 Subject: [l18n] Improved few source strings --- module/plugins/hooks/UpdateManager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 04e5a8698..f017acd92 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -14,7 +14,7 @@ from module.plugins.Hook import Expose, Hook, threaded class UpdateManager(Hook): __name__ = "UpdateManager" - __version__ = "0.30" + __version__ = "0.31" __description__ = """Check for updates""" __config__ = [("activated", "bool", "Activated", True), ("mode", "pyLoad + plugins;plugins only", "Check updates for", "pyLoad + plugins"), @@ -101,7 +101,7 @@ class UpdateManager(Hook): try: return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() except: - self.logWarning(_("Not able to connect server to get updates")) + self.logWarning(_("Unable to contact server to get updates")) @Expose def updatePlugins(self): @@ -115,7 +115,7 @@ class UpdateManager(Hook): if not data: r = False elif data[0] == "None": - self.logInfo(_("No pyLoad version available")) + self.logInfo(_("No new pyLoad version available")) updates = data[1:] r = self._updatePlugins(updates) elif onlyplugin: @@ -194,7 +194,7 @@ class UpdateManager(Hook): else: raise Exception(_("Version mismatch")) except Exception, e: - self.logError(_("Error when updating plugin %s") % filename, str(e)) + self.logError(_("Error updating plugin %s") % filename, str(e)) if blacklist: removed = self.removePlugins(map(lambda x: x.split('|'), blacklist)) @@ -237,7 +237,7 @@ class UpdateManager(Hook): if isfile(pyc): remove(pyc) except Exception, e: - self.logError("Error when deleting %s" % id, str(e)) + self.logError("Error deleting %s" % id, str(e)) else: removed.append(id) -- cgit v1.2.3 From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/hooks/AlldebridCom.py | 1 + module/plugins/hooks/BypassCaptcha.py | 8 +++++--- module/plugins/hooks/Captcha9kw.py | 8 +++++--- module/plugins/hooks/CaptchaBrotherhood.py | 8 +++++--- module/plugins/hooks/Checksum.py | 8 +++++--- module/plugins/hooks/ClickAndLoad.py | 9 +++++---- module/plugins/hooks/DeathByCaptcha.py | 8 +++++--- module/plugins/hooks/DebridItaliaCom.py | 2 ++ module/plugins/hooks/DeleteFinished.py | 16 ++++++++-------- module/plugins/hooks/DownloadScheduler.py | 7 +++++-- module/plugins/hooks/EasybytezCom.py | 3 +++ module/plugins/hooks/Ev0InFetcher.py | 8 +++++--- module/plugins/hooks/ExpertDecoders.py | 8 +++++--- module/plugins/hooks/ExternalScripts.py | 9 +++++---- module/plugins/hooks/ExtractArchive.py | 10 +++++++--- module/plugins/hooks/FastixRu.py | 3 +++ module/plugins/hooks/FreeWayMe.py | 7 ++++--- module/plugins/hooks/HotFolder.py | 9 +++++---- module/plugins/hooks/IRCInterface.py | 10 +++++----- module/plugins/hooks/ImageTyperz.py | 8 +++++--- module/plugins/hooks/LinkdecrypterCom.py | 8 +++++--- module/plugins/hooks/LinksnappyCom.py | 2 ++ module/plugins/hooks/MegaDebridEu.py | 3 +++ module/plugins/hooks/MergeFiles.py | 12 +++++++----- module/plugins/hooks/MultiDebridCom.py | 2 ++ module/plugins/hooks/MultiHome.py | 8 +++++--- module/plugins/hooks/MultishareCz.py | 3 +++ module/plugins/hooks/OverLoadMe.py | 3 +++ module/plugins/hooks/Premium4Me.py | 2 ++ module/plugins/hooks/PremiumizeMe.py | 3 ++- module/plugins/hooks/RPNetBiz.py | 5 ++++- module/plugins/hooks/RealdebridCom.py | 2 ++ module/plugins/hooks/RehostTo.py | 1 + module/plugins/hooks/RestartFailed.py | 5 ++++- module/plugins/hooks/SimplyPremiumCom.py | 3 +++ module/plugins/hooks/SimplydebridCom.py | 3 +++ module/plugins/hooks/UnSkipOnFail.py | 10 ++++++---- module/plugins/hooks/UnrestrictLi.py | 2 ++ module/plugins/hooks/UpdateManager.py | 5 ++++- module/plugins/hooks/WindowsPhoneToastNotify.py | 12 +++++++----- module/plugins/hooks/XFileSharingPro.py | 3 +++ module/plugins/hooks/XMPPInterface.py | 9 +++++---- module/plugins/hooks/ZeveraCom.py | 3 +++ 43 files changed, 174 insertions(+), 85 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index 0f8d3bfbb..1ef9b252a 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -22,6 +22,7 @@ class AlldebridCom(MultiHoster): __author_name__ = "Andy Voigt" __author_mail__ = "spamsales@online.de" + def getHoster(self): https = "https" if self.getConfig("https") else "http" page = getURL(https + "://www.alldebrid.com/api.php?action=get_host").replace("\"", "").strip() diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 70e60f56c..1c9c4e722 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: RaNaN, Godofdream, zoidberg """ from thread import start_new_thread @@ -45,10 +43,13 @@ class BypassCaptchaException(Exception): class BypassCaptcha(Hook): __name__ = "BypassCaptcha" __version__ = "0.04" - __description__ = """Send captchas to BypassCaptcha.com""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("force", "bool", "Force BC even if client is connected", False), ("passkey", "password", "Passkey", "")] + + __description__ = """Send captchas to BypassCaptcha.com""" __author_name__ = ("RaNaN", "Godofdream", "zoidberg") __author_mail__ = ("RaNaN@pyload.org", "soilfcition@gmail.com", "zoidberg@mujmail.cz") @@ -56,6 +57,7 @@ class BypassCaptcha(Hook): RESPOND_URL = "http://bypasscaptcha.com/check_value.php" GETCREDITS_URL = "http://bypasscaptcha.com/ex_left.php" + def setup(self): self.info = {} diff --git a/module/plugins/hooks/Captcha9kw.py b/module/plugins/hooks/Captcha9kw.py index c86f92972..28bce3d2b 100755 --- a/module/plugins/hooks/Captcha9kw.py +++ b/module/plugins/hooks/Captcha9kw.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: mkaay, RaNaN, zoidberg """ from __future__ import with_statement @@ -31,7 +29,8 @@ from module.plugins.Hook import Hook class Captcha9kw(Hook): __name__ = "Captcha9kw" __version__ = "0.09" - __description__ = """Send captchas to 9kw.eu""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("force", "bool", "Force CT even if client is connected", True), ("https", "bool", "Enable HTTPS", False), @@ -43,11 +42,14 @@ class Captcha9kw(Hook): False), ("timeout", "int", "Timeout (max. 300)", 300), ("passkey", "password", "API key", "")] + + __description__ = """Send captchas to 9kw.eu""" __author_name__ = "RaNaN" __author_mail__ = "RaNaN@pyload.org" API_URL = "://www.9kw.eu/index.cgi" + def setup(self): self.API_URL = "https" + self.API_URL if self.getConfig("https") else "http" + self.API_URL self.info = {} diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 23d71ff5f..86768b76b 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: mkaay, RaNaN, zoidberg """ from __future__ import with_statement @@ -47,16 +45,20 @@ class CaptchaBrotherhoodException(Exception): class CaptchaBrotherhood(Hook): __name__ = "CaptchaBrotherhood" __version__ = "0.05" - __description__ = """Send captchas to CaptchaBrotherhood.com""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("username", "str", "Username", ""), ("force", "bool", "Force CT even if client is connected", False), ("passkey", "password", "Password", "")] + + __description__ = """Send captchas to CaptchaBrotherhood.com""" __author_name__ = ("RaNaN", "zoidberg") __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") API_URL = "http://www.captchabrotherhood.com/" + def setup(self): self.info = {} diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index af37d69e6..8566a847e 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: zoidberg """ from __future__ import with_statement @@ -55,12 +53,15 @@ def computeChecksum(local_file, algorithm): class Checksum(Hook): __name__ = "Checksum" __version__ = "0.12" - __description__ = """Verify downloaded file size and checksum""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("check_action", "fail;retry;nothing", "What to do if check fails?", "retry"), ("max_tries", "int", "Number of retries", 2), ("retry_action", "fail;nothing", "What to do if all retries fail?", "fail"), ("wait_time", "int", "Time to wait before each retry (seconds)", 1)] + + __description__ = """Verify downloaded file size and checksum""" __author_name__ = ("zoidberg", "Walter Purcaro") __author_mail__ = ("zoidberg@mujmail.cz", "vuolter@gmail.com") @@ -70,6 +71,7 @@ class Checksum(Hook): 'crc': r'filename=(?P.+)\nsize=(?P\d+)\ncrc32=(?P[0-9A-Fa-f]{8})$', 'default': r'^(?P[0-9A-Fa-f]+)\s+\*?(?P.+)$'} + def coreReady(self): if not self.config['general']['checksum']: self.logInfo("Checksum validation is disabled in general configuration") diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 002fd4cd7..3c47d30ce 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -13,9 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: RaNaN - @interface-version: 0.2 """ import socket @@ -27,12 +24,16 @@ from module.plugins.Hook import Hook class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __version__ = "0.22" - __description__ = """Gives abillity to use jd's click and load. depends on webinterface""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", True), ("extern", "bool", "Allow external link adding", False)] + + __description__ = """Gives abillity to use jd's click and load. depends on webinterface""" __author_name__ = ("RaNaN", "mkaay") __author_mail__ = ("RaNaN@pyload.de", "mkaay@mkaay.de") + def coreReady(self): self.port = int(self.config['webinterface']['port']) if self.config['webinterface']['activated']: diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index f7bc1b90f..5a5ab7933 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: mkaay, RaNaN, zoidberg """ from __future__ import with_statement @@ -62,16 +60,20 @@ class DeathByCaptchaException(Exception): class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" __version__ = "0.03" - __description__ = """Send captchas to DeathByCaptcha.com""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("username", "str", "Username", ""), ("passkey", "password", "Password", ""), ("force", "bool", "Force DBC even if client is connected", False)] + + __description__ = """Send captchas to DeathByCaptcha.com""" __author_name__ = ("RaNaN", "zoidberg") __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") API_URL = "http://api.dbcapi.me/api/" + def setup(self): self.info = {} diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py index fb6be674f..1a081da7a 100644 --- a/module/plugins/hooks/DebridItaliaCom.py +++ b/module/plugins/hooks/DebridItaliaCom.py @@ -21,6 +21,7 @@ class DebridItaliaCom(MultiHoster): __name__ = "DebridItaliaCom" __version__ = "0.07" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), @@ -31,6 +32,7 @@ class DebridItaliaCom(MultiHoster): __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" + def getHoster(self): return ["netload.in", "hotfile.com", "rapidshare.com", "multiupload.com", "uploading.com", "megashares.com", "crocko.com", "filepost.com", diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 3bc98a7b3..48b262392 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: Walter Purcaro """ from module.database import style @@ -24,15 +22,17 @@ from module.plugins.Hook import Hook class DeleteFinished(Hook): __name__ = 'DeleteFinished' __version__ = '1.09' - __description__ = 'Automatically delete all finished packages from queue' - __config__ = [ - ('activated', 'bool', 'Activated', 'False'), - ('interval', 'int', 'Delete every (hours)', '72'), - ('deloffline', 'bool', 'Delete packages with offline links', 'False') - ] + __type__ = "hook" + + __config__ = [('activated', 'bool', 'Activated', 'False'), + ('interval', 'int', 'Delete every (hours)', '72'), + ('deloffline', 'bool', 'Delete packages with offline links', 'False')] + + __description__ = """Automatically delete all finished packages from queue""" __author_name__ = ('Walter Purcaro') __author_mail__ = ('vuolter@gmail.com') + ## overwritten methods ## def periodical(self): if not self.info['sleep']: diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 41a20e5d1..070c0634e 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -12,7 +12,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - @author: zoidberg Original idea by new.cze """ @@ -25,14 +24,18 @@ from module.plugins.Hook import Hook class DownloadScheduler(Hook): __name__ = "DownloadScheduler" __version__ = "0.21" - __description__ = """Download Scheduler""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("timetable", "str", "List time periods as hh:mm full or number(kB/s)", "0:00 full, 7:00 250, 10:00 0, 17:00 150"), ("abort", "bool", "Abort active downloads when start period with speed 0", False)] + + __description__ = """Download Scheduler""" __author_name__ = ("zoidberg", "stickell") __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it") + def setup(self): self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index a3a2dcb92..d3cda7b80 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -9,13 +9,16 @@ class EasybytezCom(MultiHoster): __name__ = "EasybytezCom" __version__ = "0.03" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", "")] + __description__ = """EasyBytez.com hook plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" + def getHoster(self): self.account = self.core.accountManager.getAccountPlugin(self.__name__) user = self.account.selectAccount()[0] diff --git a/module/plugins/hooks/Ev0InFetcher.py b/module/plugins/hooks/Ev0InFetcher.py index 1e2b62062..d2caa19ac 100644 --- a/module/plugins/hooks/Ev0InFetcher.py +++ b/module/plugins/hooks/Ev0InFetcher.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: mkaay """ from time import mktime, time @@ -25,7 +23,8 @@ from module.plugins.Hook import Hook class Ev0InFetcher(Hook): __name__ = "Ev0InFetcher" __version__ = "0.21" - __description__ = """Checks rss feeds for Ev0.in""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("interval", "int", "Check interval in minutes", 10), ("queue", "bool", "Move new shows directly to Queue", False), @@ -33,9 +32,12 @@ class Ev0InFetcher(Hook): ("quality", "xvid;x264;rmvb", "Video Format", "xvid"), ("hoster", "str", "Hoster to use (comma seperated)", "NetloadIn,RapidshareCom,MegauploadCom,HotfileCom")] + + __description__ = """Checks rss feeds for Ev0.in""" __author_name__ = "mkaay" __author_mail__ = "mkaay@mkaay.de" + def setup(self): self.interval = self.getConfig("interval") * 60 diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index 7be30f86e..65edd487b 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: mkaay, RaNaN, zoidberg """ from __future__ import with_statement @@ -32,15 +30,19 @@ from module.plugins.Hook import Hook class ExpertDecoders(Hook): __name__ = "ExpertDecoders" __version__ = "0.01" - __description__ = """Send captchas to expertdecoders.com""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("force", "bool", "Force CT even if client is connected", False), ("passkey", "password", "Access key", "")] + + __description__ = """Send captchas to expertdecoders.com""" __author_name__ = ("RaNaN", "zoidberg") __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") API_URL = "http://www.fasttypers.org/imagepost.ashx" + def setup(self): self.info = {} diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 3d84dcc3d..55aae1093 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -13,9 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: mkaay - @interface-version: 0.1 """ import subprocess @@ -29,13 +26,17 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __version__ = "0.23" - __description__ = """Run external scripts""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", True)] + + __description__ = """Run external scripts""" __author_name__ = ("mkaay", "RaNaN", "spoob") __author_mail__ = ("mkaay@mkaay.de", "ranan@pyload.org", "spoob@pyload.org") event_list = ["unrarFinished", "allDownloadsFinished", "allDownloadsProcessed"] + def setup(self): self.scripts = {} diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 12e53fe50..a2e7d1dac 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -59,7 +59,8 @@ class ExtractArchive(Hook): """ __name__ = "ExtractArchive" __version__ = "0.16" - __description__ = """Extract different kind of archives""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", True), ("fullpath", "bool", "Extract full path", True), ("overwrite", "bool", "Overwrite files", True), @@ -71,11 +72,14 @@ class ExtractArchive(Hook): ("recursive", "bool", "Extract archives in archvies", True), ("queue", "bool", "Wait for all downloads to be finished", True), ("renice", "int", "CPU Priority", 0)] - __author_name__ = ("pyload Team", "AndroKev") - __author_mail__ = ("adminpyload.org", "@pyloadforum") + + __description__ = """Extract different kind of archives""" + __author_name__ = ("pyLoad Team", "AndroKev") + __author_mail__ = ("admin@pyload.org", "@pyloadforum") event_list = ["allDownloadsProcessed"] + def setup(self): self.plugins = [] self.passwords = [] diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py index 558da1b86..aa020ea37 100644 --- a/module/plugins/hooks/FastixRu.py +++ b/module/plugins/hooks/FastixRu.py @@ -11,14 +11,17 @@ class FastixRu(MultiHoster): __name__ = "FastixRu" __version__ = "0.02" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("unloadFailing", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __description__ = """Fastix.ru hook plugin""" __author_name__ = "Massimo Rosamilia" __author_mail__ = "max@spiritix.eu" + def getHoster(self): page = getURL( "http://fastix.ru/api_v2/?apikey=5182964c3f8f9a7f0b00000a_kelmFB4n1IrnCDYuIFn2y&sub=allowed_sources") diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index 7d4bcc852..3d2f7fcef 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: Nicolas Giese """ from module.network.RequestFactory import getURL @@ -25,15 +23,18 @@ class FreeWayMe(MultiHoster): __name__ = "FreeWayMe" __version__ = "0.11" __type__ = "hook" - __description__ = """FreeWay.me hook plugin""" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + + __description__ = """FreeWay.me hook plugin""" __author_name__ = "Nicolas Giese" __author_mail__ = "james@free-way.me" + def getHoster(self): hostis = getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3}).replace("\"", "").strip() self.logDebug("hosters: %s" % hostis) diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index a63b314d1..bd57712af 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -13,9 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: RaNaN - @interface-version: 0.2 """ from os import makedirs @@ -32,15 +29,19 @@ from module.plugins.Hook import Hook class HotFolder(Hook): __name__ = "HotFolder" __version__ = "0.11" - __description__ = """Observe folder and file for changes and add container and links""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("folder", "str", "Folder to observe", "container"), ("watch_file", "bool", "Observe link file", False), ("keep", "bool", "Keep added containers", True), ("file", "str", "Link file", "links.txt")] + + __description__ = """Observe folder and file for changes and add container and links""" __author_name__ = "RaNaN" __author_mail__ = "RaNaN@pyload.de" + def setup(self): self.interval = 10 diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 760c1a4df..41ca352a4 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -13,10 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: RaNaN - @author: jeix - @interface-version: 0.2 """ from select import select @@ -37,7 +33,8 @@ from module.Api import PackageDoesNotExists, FileDoesNotExists class IRCInterface(Thread, Hook): __name__ = "IRCInterface" __version__ = "0.11" - __description__ = """Connect to irc and let owner perform different tasks""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("host", "str", "IRC-Server Address", "Enter your server here!"), ("port", "int", "IRC-Server Port", 6667), @@ -48,9 +45,12 @@ class IRCInterface(Thread, Hook): ("info_file", "bool", "Inform about every file finished", False), ("info_pack", "bool", "Inform about every package finished", True), ("captcha", "bool", "Send captcha requests", True)] + + __description__ = """Connect to irc and let owner perform different tasks""" __author_name__ = "Jeix" __author_mail__ = "Jeix@hasnomail.com" + def __init__(self, core, manager): Thread.__init__(self) Hook.__init__(self, core, manager) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index e2e9d93d5..3c23f9567 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: mkaay, RaNaN, zoidberg """ from __future__ import with_statement from thread import start_new_thread @@ -43,11 +41,14 @@ class ImageTyperzException(Exception): class ImageTyperz(Hook): __name__ = "ImageTyperz" __version__ = "0.04" - __description__ = """Send captchas to ImageTyperz.com""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("username", "str", "Username", ""), ("passkey", "password", "Password", ""), ("force", "bool", "Force IT even if client is connected", False)] + + __description__ = """Send captchas to ImageTyperz.com""" __author_name__ = ("RaNaN", "zoidberg") __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") @@ -55,6 +56,7 @@ class ImageTyperz(Hook): RESPOND_URL = "http://captchatypers.com/Forms/SetBadImage.ashx" GETCREDITS_URL = "http://captchatypers.com/Forms/RequestBalance.ashx" + def setup(self): self.info = {} diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index dd9cd79f2..75995faf2 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: zoidberg """ import re @@ -27,11 +25,15 @@ from module.utils import remove_chars class LinkdecrypterCom(Hook): __name__ = "LinkdecrypterCom" __version__ = "0.19" - __description__ = """Linkdecrypter.com hook plugin""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False)] + + __description__ = """Linkdecrypter.com hook plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" + def coreReady(self): try: self.loadPatterns() diff --git a/module/plugins/hooks/LinksnappyCom.py b/module/plugins/hooks/LinksnappyCom.py index 110731228..a0e5b8d38 100644 --- a/module/plugins/hooks/LinksnappyCom.py +++ b/module/plugins/hooks/LinksnappyCom.py @@ -9,6 +9,7 @@ class LinksnappyCom(MultiHoster): __name__ = "LinksnappyCom" __version__ = "0.01" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), @@ -19,6 +20,7 @@ class LinksnappyCom(MultiHoster): __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" + def getHoster(self): json_data = getURL('http://gen.linksnappy.com/lseAPI.php?act=FILEHOSTS') json_data = json_loads(json_data) diff --git a/module/plugins/hooks/MegaDebridEu.py b/module/plugins/hooks/MegaDebridEu.py index 0c3bb99f6..31be74fdd 100644 --- a/module/plugins/hooks/MegaDebridEu.py +++ b/module/plugins/hooks/MegaDebridEu.py @@ -23,12 +23,15 @@ class MegaDebridEu(MultiHoster): __name__ = "MegaDebridEu" __version__ = "0.02" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("unloadFailing", "bool", "Revert to standard download if download fails", False)] + __description__ = """mega-debrid.eu hook plugin""" __author_name__ = "D.Ducatel" __author_mail__ = "dducatel@je-geek.fr" + def getHoster(self): reponse = getURL('http://www.mega-debrid.eu/api.php?action=getHosters') json_data = json_loads(reponse) diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 99b0aafc6..e7bd63d17 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: and9000 """ import os @@ -23,7 +21,7 @@ import traceback from os.path import join from module.utils import save_join, fs_encode -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, threaded BUFFER_SIZE = 4096 @@ -31,16 +29,20 @@ BUFFER_SIZE = 4096 class MergeFiles(Hook): __name__ = "MergeFiles" __version__ = "0.12" - __description__ = """Merges parts splitted with hjsplit""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False)] - __threaded__ = ["packageFinished"] + + __description__ = """Merges parts splitted with hjsplit""" __author_name__ = "and9000" __author_mail__ = "me@has-no-mail.com" + def setup(self): # nothing to do pass + @threaded def packageFinished(self, pack): files = {} fid_dict = {} diff --git a/module/plugins/hooks/MultiDebridCom.py b/module/plugins/hooks/MultiDebridCom.py index f2dfb18ca..3309fb9a8 100644 --- a/module/plugins/hooks/MultiDebridCom.py +++ b/module/plugins/hooks/MultiDebridCom.py @@ -23,6 +23,7 @@ class MultiDebridCom(MultiHoster): __name__ = "MultiDebridCom" __version__ = "0.01" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), @@ -33,6 +34,7 @@ class MultiDebridCom(MultiHoster): __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" + def getHoster(self): json_data = getURL('http://multi-debrid.com/api.php?hosts', decode=True) self.logDebug('JSON data: ' + json_data) diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index b1635a588..5a7e53b0d 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: mkaay """ from time import time @@ -25,12 +23,16 @@ from module.plugins.Hook import Hook class MultiHome(Hook): __name__ = "MultiHome" __version__ = "0.11" - __description__ = """Ip address changer""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("interfaces", "str", "Interfaces", "None")] + + __description__ = """Ip address changer""" __author_name__ = "mkaay" __author_mail__ = "mkaay@mkaay.de" + def setup(self): self.register = {} self.interfaces = [] diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py index 0291738f5..8baa4bb07 100644 --- a/module/plugins/hooks/MultishareCz.py +++ b/module/plugins/hooks/MultishareCz.py @@ -10,15 +10,18 @@ class MultishareCz(MultiHoster): __name__ = "MultishareCz" __version__ = "0.04" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", "uloz.to")] + __description__ = """MultiShare.cz hook plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" HOSTER_PATTERN = r']*?alt="([^"]+)">\s*[^>]*?alt="OK"' + def getHoster(self): page = getURL("http://www.multishare.cz/monitoring/") return re.findall(self.HOSTER_PATTERN, page) diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index e15d0b05f..dcc57aa75 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -8,16 +8,19 @@ class OverLoadMe(MultiHoster): __name__ = "OverLoadMe" __version__ = "0.01" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("https", "bool", "Enable HTTPS", True), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), ("unloadFailing", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 12)] + __description__ = """Over-Load.me hook plugin""" __author_name__ = "marley" __author_mail__ = "marley@over-load.me" + def getHoster(self): https = "https" if self.getConfig("https") else "http" page = getURL(https + "://api.over-load.me/hoster.php", diff --git a/module/plugins/hooks/Premium4Me.py b/module/plugins/hooks/Premium4Me.py index 57b188bb9..242e72f3e 100644 --- a/module/plugins/hooks/Premium4Me.py +++ b/module/plugins/hooks/Premium4Me.py @@ -12,10 +12,12 @@ class Premium4Me(MultiHoster): __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), ("hosterList", "str", "Hoster list (comma separated)", "")] + __description__ = """Premium.to hook plugin""" __author_name__ = ("RaNaN", "zoidberg", "stickell") __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") + def getHoster(self): page = getURL("http://premium.to/api/hosters.php?authcode=%s" % self.account.authcode) return [x.strip() for x in page.replace("\"", "").split(";")] diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py index 9f1a70a70..1a35460de 100644 --- a/module/plugins/hooks/PremiumizeMe.py +++ b/module/plugins/hooks/PremiumizeMe.py @@ -10,7 +10,6 @@ class PremiumizeMe(MultiHoster): __name__ = "PremiumizeMe" __version__ = "0.12" __type__ = "hook" - __description__ = """Premiumize.me hook plugin""" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), @@ -18,9 +17,11 @@ class PremiumizeMe(MultiHoster): ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __description__ = """Premiumize.me hook plugin""" __author_name__ = "Florian Franzen" __author_mail__ = "FlorianFranzen@gmail.com" + def getHoster(self): # If no accounts are available there will be no hosters available if not self.account or not self.account.canUse(): diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py index 54f814231..36cf69b4b 100644 --- a/module/plugins/hooks/RPNetBiz.py +++ b/module/plugins/hooks/RPNetBiz.py @@ -9,15 +9,18 @@ class RPNetBiz(MultiHoster): __name__ = "RPNetBiz" __version__ = "0.1" __type__ = "hook" - __description__ = """RPNet.biz hook plugin""" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + + __description__ = """RPNet.biz hook plugin""" __author_name__ = "Dman" __author_mail__ = "dmanugm@gmail.com" + def getHoster(self): # No hosts supported if no account if not self.account or not self.account.canUse(): diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index 566f9005f..4477fba4a 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -15,10 +15,12 @@ class RealdebridCom(MultiHoster): ("hosterList", "str", "Hoster list (comma separated)", ""), ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __description__ = """Real-Debrid.com hook plugin""" __author_name__ = "Devirex Hazzard" __author_mail__ = "naibaf_11@yahoo.de" + def getHoster(self): https = "https" if self.getConfig("https") else "http" page = getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 6c3a77ca3..0841e07a6 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -19,6 +19,7 @@ class RehostTo(MultiHoster): __author_name__ = "RaNaN" __author_mail__ = "RaNaN@pyload.org" + def getHoster(self): page = getURL("http://rehost.to/api.php?cmd=get_supported_och_dl&long_ses=%s" % self.long_ses) return [x.strip() for x in page.replace("\"", "").split(",")] diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 3ee2aeed4..2bd0e28db 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -20,9 +20,12 @@ from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" __version__ = "1.55" - __description__ = """Periodically restart all failed downloads in queue""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("interval", "int", "Check interval in minutes", 90)] + + __description__ = """Periodically restart all failed downloads in queue""" __author_name__ = "Walter Purcaro" __author_mail__ = "vuolter@gmail.com" diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py index 60d164c66..dbba3d1e9 100644 --- a/module/plugins/hooks/SimplyPremiumCom.py +++ b/module/plugins/hooks/SimplyPremiumCom.py @@ -24,15 +24,18 @@ class SimplyPremiumCom(MultiHoster): __name__ = "SimplyPremiumCom" __version__ = "0.02" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", "False"), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), ("unloadFailing", "bool", "Revert to standard download if download fails", "False"), ("interval", "int", "Reload interval in hours (0 to disable)", "24")] + __description__ = """Simply-Premium.Com hook plugin""" __author_name__ = "EvolutionClip" __author_mail__ = "evolutionclip@live.de" + def getHoster(self): json_data = getURL('http://www.simply-premium.com/api/hosts.php?format=json&online=1') json_data = json_loads(json_data) diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py index a523d2404..345d37e4a 100644 --- a/module/plugins/hooks/SimplydebridCom.py +++ b/module/plugins/hooks/SimplydebridCom.py @@ -8,13 +8,16 @@ class SimplydebridCom(MultiHoster): __name__ = "SimplydebridCom" __version__ = "0.01" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", "")] + __description__ = """Simply-Debrid.com hook plugin""" __author_name__ = "Kagenoshin" __author_mail__ = "kagenoshin@gmx.ch" + def getHoster(self): page = getURL("http://simply-debrid.com/api.php?list=1") return [x.strip() for x in page.rstrip(';').replace("\"", "").split(";")] diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index af6039ecd..f25482b79 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: hgg """ from os.path import basename @@ -26,10 +24,14 @@ from module.PyFile import PyFile class UnSkipOnFail(Hook): __name__ = 'UnSkipOnFail' __version__ = '0.01' - __description__ = """When a download fails, restart skipped duplicates""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", True)] + + __description__ = """When a download fails, restart skipped duplicates""" __author_name__ = "hagg" - __author_mail__ = "" + __author_mail__ = None + def downloadFailed(self, pyfile): pyfile_name = basename(pyfile.name) diff --git a/module/plugins/hooks/UnrestrictLi.py b/module/plugins/hooks/UnrestrictLi.py index 4f8f11625..3303c7355 100644 --- a/module/plugins/hooks/UnrestrictLi.py +++ b/module/plugins/hooks/UnrestrictLi.py @@ -23,6 +23,7 @@ class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" __version__ = "0.02" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), @@ -34,6 +35,7 @@ class UnrestrictLi(MultiHoster): __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" + def getHoster(self): json_data = getURL('http://unrestrict.li/api/jdownloader/hosts.php?format=json') json_data = json_loads(json_data) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index f017acd92..242659d9e 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -15,12 +15,15 @@ from module.plugins.Hook import Expose, Hook, threaded class UpdateManager(Hook): __name__ = "UpdateManager" __version__ = "0.31" - __description__ = """Check for updates""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", True), ("mode", "pyLoad + plugins;plugins only", "Check updates for", "pyLoad + plugins"), ("interval", "int", "Check interval in hours", 8), ("reloadplugins", "bool", "Monitor plugins for code changes (debug mode only)", True), ("nodebugupdate", "bool", "Don't check for updates in debug mode", True)] + + __description__ = """Check for updates""" __author_name__ = "Walter Purcaro" __author_mail__ = "vuolter@gmail.com" diff --git a/module/plugins/hooks/WindowsPhoneToastNotify.py b/module/plugins/hooks/WindowsPhoneToastNotify.py index 7c005fcbb..25fa3abe5 100644 --- a/module/plugins/hooks/WindowsPhoneToastNotify.py +++ b/module/plugins/hooks/WindowsPhoneToastNotify.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: RaNaN, Godofdream, zoidberg """ import time import httplib @@ -24,15 +22,19 @@ from module.plugins.Hook import Hook class WindowsPhoneToastNotify(Hook): __name__ = "WindowsPhoneToastNotify" __version__ = "0.02" - __description__ = """Send push notifications to Windows Phone""" - __author_name__ = "Andy Voigt" - __author_mail__ = "phone-support@hotmail.de" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("force", "bool", "Force even if client is connected", False), ("pushId", "str", "pushId", ""), ("pushUrl", "str", "pushUrl", ""), ("pushTimeout", "int", "Timeout between notifications in seconds", 0)] + __description__ = """Send push notifications to Windows Phone""" + __author_name__ = "Andy Voigt" + __author_mail__ = "phone-support@hotmail.de" + + def setup(self): self.info = {} diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 19ecc08b6..09d035e10 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -9,14 +9,17 @@ class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __version__ = "0.11" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", True), ("loadDefault", "bool", "Include default (built-in) hoster list", True), ("includeList", "str", "Include hosters (comma separated)", ""), ("excludeList", "str", "Exclude hosters (comma separated)", "")] + __description__ = """XFileSharingPro hook plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" + def coreReady(self): self.loadPattern() diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 5ecf4e153..7b179d41a 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -13,9 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: RaNaN - @interface-version: 0.2 """ from pyxmpp import streamtls @@ -30,7 +27,8 @@ from module.plugins.hooks.IRCInterface import IRCInterface class XMPPInterface(IRCInterface, JabberClient): __name__ = "XMPPInterface" __version__ = "0.11" - __description__ = """Connect to jabber and let owner perform different tasks""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("jid", "str", "Jabber ID", "user@exmaple-jabber-server.org"), ("pw", "str", "Password", ""), @@ -39,9 +37,12 @@ class XMPPInterface(IRCInterface, JabberClient): ("info_file", "bool", "Inform about every file finished", False), ("info_pack", "bool", "Inform about every package finished", True), ("captcha", "bool", "Send captcha requests", True)] + + __description__ = """Connect to jabber and let owner perform different tasks""" __author_name__ = "RaNaN" __author_mail__ = "RaNaN@pyload.org" + implements(IMessageHandlersProvider) def __init__(self, core, manager): diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index 4dee83ccb..49fc68b30 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -8,13 +8,16 @@ class ZeveraCom(MultiHoster): __name__ = "ZeveraCom" __version__ = "0.02" __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", "")] + __description__ = """Real-Debrid.com hook plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" + def getHoster(self): page = getURL("http://www.zevera.com/jDownloader.ashx?cmd=gethosters") return [x.strip() for x in page.replace("\"", "").split(",")] -- cgit v1.2.3 From 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:25:41 +0200 Subject: Fix code indentation, some bad whitespaces and missing authors + use 'not' instead 'is None' + replace __pattern__'s r" with r' + other minor cosmetics --- module/plugins/hooks/BypassCaptcha.py | 1 + module/plugins/hooks/CaptchaBrotherhood.py | 1 + module/plugins/hooks/DeleteFinished.py | 8 ++++---- module/plugins/hooks/DownloadScheduler.py | 2 +- module/plugins/hooks/Ev0InFetcher.py | 2 ++ module/plugins/hooks/HotFolder.py | 1 - module/plugins/hooks/IRCInterface.py | 3 +-- module/plugins/hooks/ImageTyperz.py | 1 + module/plugins/hooks/MultiHome.py | 1 + module/plugins/hooks/SimplyPremiumCom.py | 7 +++---- module/plugins/hooks/UnSkipOnFail.py | 4 ++-- module/plugins/hooks/XMPPInterface.py | 2 +- 12 files changed, 18 insertions(+), 15 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 1c9c4e722..05cf29500 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -27,6 +27,7 @@ PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32" class BypassCaptchaException(Exception): + def __init__(self, err): self.err = err diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 86768b76b..b413bdb59 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -29,6 +29,7 @@ from module.plugins.Hook import Hook class CaptchaBrotherhoodException(Exception): + def __init__(self, err): self.err = err diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 48b262392..1c80facc9 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -20,8 +20,8 @@ from module.plugins.Hook import Hook class DeleteFinished(Hook): - __name__ = 'DeleteFinished' - __version__ = '1.09' + __name__ = "DeleteFinished" + __version__ = "1.09" __type__ = "hook" __config__ = [('activated', 'bool', 'Activated', 'False'), @@ -29,8 +29,8 @@ class DeleteFinished(Hook): ('deloffline', 'bool', 'Delete packages with offline links', 'False')] __description__ = """Automatically delete all finished packages from queue""" - __author_name__ = ('Walter Purcaro') - __author_mail__ = ('vuolter@gmail.com') + __author_name__ = "Walter Purcaro" + __author_mail__ = "vuolter@gmail.com" ## overwritten methods ## diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 070c0634e..dbc1019e3 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -43,7 +43,7 @@ class DownloadScheduler(Hook): self.updateSchedule() def updateSchedule(self, schedule=None): - if schedule is None: + if not schedule: schedule = self.getConfig("timetable") schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", diff --git a/module/plugins/hooks/Ev0InFetcher.py b/module/plugins/hooks/Ev0InFetcher.py index d2caa19ac..3a98abbf7 100644 --- a/module/plugins/hooks/Ev0InFetcher.py +++ b/module/plugins/hooks/Ev0InFetcher.py @@ -57,7 +57,9 @@ class Ev0InFetcher(Hook): continue return [] + def periodical(self): + def normalizefiletitle(filename): filename = filename.replace('.', ' ') filename = filename.replace('_', ' ') diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index bd57712af..08ef93812 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -46,7 +46,6 @@ class HotFolder(Hook): self.interval = 10 def periodical(self): - if not exists(join(self.getConfig("folder"), "finished")): makedirs(join(self.getConfig("folder"), "finished")) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 41ca352a4..7dbe835c7 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -311,12 +311,10 @@ class IRCInterface(Thread, Hook): return lines def event_start(self, args): - self.api.unpauseServer() return ["INFO: Starting downloads."] def event_stop(self, args): - self.api.pauseServer() return ["INFO: No new downloads will be started."] @@ -415,6 +413,7 @@ class IRCInterface(Thread, Hook): class IRCError(Exception): + def __init__(self, value): self.value = value diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 3c23f9567..794db3913 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -25,6 +25,7 @@ from module.plugins.Hook import Hook class ImageTyperzException(Exception): + def __init__(self, err): self.err = err diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 5a7e53b0d..31bbbcc9a 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -73,6 +73,7 @@ class MultiHome(Hook): class Interface(object): + def __init__(self, adress): self.adress = adress self.history = {} diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py index dbba3d1e9..41268e231 100644 --- a/module/plugins/hooks/SimplyPremiumCom.py +++ b/module/plugins/hooks/SimplyPremiumCom.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - ############################################################################ # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU Affero General Public License as # @@ -15,9 +14,9 @@ # along with this program. If not, see . # ############################################################################ -from module.plugins.internal.MultiHoster import MultiHoster -from module.network.RequestFactory import getURL from module.common.json_layer import json_loads +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster class SimplyPremiumCom(MultiHoster): @@ -31,7 +30,7 @@ class SimplyPremiumCom(MultiHoster): ("unloadFailing", "bool", "Revert to standard download if download fails", "False"), ("interval", "int", "Reload interval in hours (0 to disable)", "24")] - __description__ = """Simply-Premium.Com hook plugin""" + __description__ = """Simply-Premium.com hook plugin""" __author_name__ = "EvolutionClip" __author_mail__ = "evolutionclip@live.de" diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index f25482b79..d40854e99 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -22,8 +22,8 @@ from module.PyFile import PyFile class UnSkipOnFail(Hook): - __name__ = 'UnSkipOnFail' - __version__ = '0.01' + __name__ = "UnSkipOnFail" + __version__ = "0.01" __type__ = "hook" __config__ = [("activated", "bool", "Activated", True)] diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 7b179d41a..57a997a4b 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -130,7 +130,7 @@ class XMPPInterface(IRCInterface, JabberClient): subject = stanza.get_subject() body = stanza.get_body() t = stanza.get_type() - self.logDebug(u'pyLoad XMPP: Message from %s received.' % (unicode(stanza.get_from(), ))) + self.logDebug(u'pyLoad XMPP: Message from %s received.' % (unicode(stanza.get_from(),))) self.logDebug(u'pyLoad XMPP: Body: %s Subject: %s Type: %s' % (body, subject, t)) if t == "headline": -- cgit v1.2.3 From 7b8c458cca7d21a029620f98e453f746fce69cd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 16:10:01 +0200 Subject: Prefer single quote for dict key name --- module/plugins/hooks/BypassCaptcha.py | 6 +++--- module/plugins/hooks/Captcha9kw.py | 8 ++++---- module/plugins/hooks/CaptchaBrotherhood.py | 4 ++-- module/plugins/hooks/Checksum.py | 18 +++++++++--------- module/plugins/hooks/DeathByCaptcha.py | 6 +++--- module/plugins/hooks/EasybytezCom.py | 6 +++--- module/plugins/hooks/ExpertDecoders.py | 6 +++--- module/plugins/hooks/ExternalScripts.py | 12 ++++++------ module/plugins/hooks/ExtractArchive.py | 14 +++++++------- module/plugins/hooks/IRCInterface.py | 24 ++++++++++++------------ module/plugins/hooks/ImageTyperz.py | 4 ++-- module/plugins/hooks/LinkdecrypterCom.py | 6 +++--- module/plugins/hooks/MegaDebridEu.py | 2 +- module/plugins/hooks/MergeFiles.py | 12 ++++++------ module/plugins/hooks/MultiHome.py | 2 +- module/plugins/hooks/RehostTo.py | 4 ++-- module/plugins/hooks/UpdateManager.py | 18 +++++++++--------- module/plugins/hooks/XFileSharingPro.py | 8 ++++---- module/plugins/hooks/XMPPInterface.py | 8 ++------ 19 files changed, 82 insertions(+), 86 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 05cf29500..5ac117818 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -125,11 +125,11 @@ class BypassCaptcha(Hook): def captchaCorrect(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: - self.respond(task.data["ticket"], True) + self.respond(task.data['ticket'], True) def captchaInvalid(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: - self.respond(task.data["ticket"], False) + self.respond(task.data['ticket'], False) def processCaptcha(self, task): c = task.captchaFile @@ -139,5 +139,5 @@ class BypassCaptcha(Hook): task.error = e.getCode() return - task.data["ticket"] = ticket + task.data['ticket'] = ticket task.setResult(result) diff --git a/module/plugins/hooks/Captcha9kw.py b/module/plugins/hooks/Captcha9kw.py index 28bce3d2b..b4e3ad34b 100755 --- a/module/plugins/hooks/Captcha9kw.py +++ b/module/plugins/hooks/Captcha9kw.py @@ -60,7 +60,7 @@ class Captcha9kw(Hook): if response.isdigit(): self.logInfo(_("%s credits left") % response) - self.info["credits"] = credits = int(response) + self.info['credits'] = credits = int(response) return credits else: self.logError(response) @@ -106,7 +106,7 @@ class Captcha9kw(Hook): time.sleep(3) result = response2 - task.data["ticket"] = response + task.data['ticket'] = response self.logInfo("result %s : %s" % (response, result)) task.setResult(result) else: @@ -142,7 +142,7 @@ class Captcha9kw(Hook): "correct": "1", "pyload": "1", "source": "pyload", - "id": task.data["ticket"]}) + "id": task.data['ticket']}) self.logInfo("Request correct: %s" % response) except BadHeader, e: @@ -161,7 +161,7 @@ class Captcha9kw(Hook): "correct": "2", "pyload": "1", "source": "pyload", - "id": task.data["ticket"]}) + "id": task.data['ticket']}) self.logInfo("Request refund: %s" % response) except BadHeader, e: diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index b413bdb59..54dfbe4d6 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -71,7 +71,7 @@ class CaptchaBrotherhood(Hook): else: credits = int(response[3:]) self.logInfo(_("%d credits left") % credits) - self.info["credits"] = credits + self.info['credits'] = credits return credits def submit(self, captcha, captchaType="file", match=None): @@ -167,5 +167,5 @@ class CaptchaBrotherhood(Hook): task.error = e.getCode() return - task.data["ticket"] = ticket + task.data['ticket'] = ticket task.setResult(result) diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 8566a847e..a51eb4b47 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -80,7 +80,7 @@ class Checksum(Hook): self.algorithms = sorted( getattr(hashlib, "algorithms", ("md5", "sha1", "sha224", "sha256", "sha384", "sha512")), reverse=True) self.algorithms.extend(["crc32", "adler32"]) - self.formats = self.algorithms + ['sfv', 'crc', 'hash'] + self.formats = self.algorithms + ["sfv", "crc", "hash"] def downloadFinished(self, pyfile): """ @@ -158,15 +158,15 @@ class Checksum(Hook): download_folder = save_join(self.config['general']['download_folder'], pypack.folder, "") for link in pypack.getChildren().itervalues(): - file_type = splitext(link["name"])[1][1:].lower() + file_type = splitext(link['name'])[1][1:].lower() #self.logDebug(link, file_type) if file_type not in self.formats: continue - hash_file = fs_encode(save_join(download_folder, link["name"])) + hash_file = fs_encode(save_join(download_folder, link['name'])) if not isfile(hash_file): - self.logWarning("File not found: %s" % link["name"]) + self.logWarning("File not found: %s" % link['name']) continue with open(hash_file) as f: @@ -174,14 +174,14 @@ class Checksum(Hook): for m in re.finditer(self.regexps.get(file_type, self.regexps['default']), text): data = m.groupdict() - self.logDebug(link["name"], data) + self.logDebug(link['name'], data) - local_file = fs_encode(save_join(download_folder, data["name"])) + local_file = fs_encode(save_join(download_folder, data['name'])) algorithm = self.methods.get(file_type, file_type) checksum = computeChecksum(local_file, algorithm) - if checksum == data["hash"]: + if checksum == data['hash']: self.logInfo('File integrity of "%s" verified by %s checksum (%s).' % - (data["name"], algorithm, checksum)) + (data['name'], algorithm, checksum)) else: self.logWarning("%s checksum for file %s does not match (%s != %s)" % - (algorithm, data["name"], checksum, data["hash"])) + (algorithm, data['name'], checksum, data['hash'])) diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 5a5ab7933..64ed2280f 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -183,7 +183,7 @@ class DeathByCaptcha(Hook): self.logError(e.getDesc()) return False - balance, rate = self.info["balance"], self.info["rate"] + balance, rate = self.info['balance'], self.info['rate'] self.logInfo("Account balance: US$%.3f (%d captchas left at %.2f cents each)" % (balance / 100, balance // rate, rate)) @@ -196,7 +196,7 @@ class DeathByCaptcha(Hook): def captchaInvalid(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: try: - response = self.call_api("captcha/%d/report" % task.data["ticket"], True) + response = self.call_api("captcha/%d/report" % task.data['ticket'], True) except DeathByCaptchaException, e: self.logError(e.getDesc()) except Exception, e: @@ -211,5 +211,5 @@ class DeathByCaptcha(Hook): self.logError(e.getDesc()) return - task.data["ticket"] = ticket + task.data['ticket'] = ticket task.setResult(result) diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index d3cda7b80..533301a4e 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -32,6 +32,6 @@ class EasybytezCom(MultiHoster): except Exception, e: self.logDebug(e) self.logWarning("Unable to load supported hoster list, using last known") - return ['bitshare.com', 'crocko.com', 'ddlstorage.com', 'depositfiles.com', 'extabit.com', 'hotfile.com', - 'mediafire.com', 'netload.in', 'rapidgator.net', 'rapidshare.com', 'uploading.com', 'uload.to', - 'uploaded.to'] + return ["bitshare.com", "crocko.com", "ddlstorage.com", "depositfiles.com", "extabit.com", "hotfile.com", + "mediafire.com", "netload.in", "rapidgator.net", "rapidshare.com", "uploading.com", "uload.to", + "uploaded.to"] diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index 65edd487b..9e151f8f6 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -51,14 +51,14 @@ class ExpertDecoders(Hook): if response.isdigit(): self.logInfo(_("%s credits left") % response) - self.info["credits"] = credits = int(response) + self.info['credits'] = credits = int(response) return credits else: self.logError(response) return 0 def processCaptcha(self, task): - task.data["ticket"] = ticket = uuid4() + task.data['ticket'] = ticket = uuid4() result = None with open(task.captchaFile, 'rb') as f: @@ -102,7 +102,7 @@ class ExpertDecoders(Hook): try: response = getURL(self.API_URL, post={"action": "refund", "key": self.getConfig("passkey"), - "gen_task_id": task.data["ticket"]}) + "gen_task_id": task.data['ticket']}) self.logInfo("Request refund: %s" % response) except BadHeader, e: diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 55aae1093..7f76df1cd 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -40,9 +40,9 @@ class ExternalScripts(Hook): def setup(self): self.scripts = {} - folders = ['download_preparing', 'download_finished', 'package_finished', - 'before_reconnect', 'after_reconnect', 'unrar_finished', - 'all_dls_finished', 'all_dls_processed'] + folders = ["download_preparing", "download_finished", "package_finished", + "before_reconnect", "after_reconnect", "unrar_finished", + "all_dls_finished", "all_dls_processed"] for folder in folders: self.scripts[folder] = [] @@ -106,13 +106,13 @@ class ExternalScripts(Hook): self.callScript(script, ip) def unrarFinished(self, folder, fname): - for script in self.scripts["unrar_finished"]: + for script in self.scripts['unrar_finished']: self.callScript(script, folder, fname) def allDownloadsFinished(self): - for script in self.scripts["all_dls_finished"]: + for script in self.scripts['all_dls_finished']: self.callScript(script) def allDownloadsProcessed(self): - for script in self.scripts["all_dls_processed"]: + for script in self.scripts['all_dls_processed']: self.callScript(script) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index a2e7d1dac..c307deb8f 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -163,7 +163,7 @@ class ExtractArchive(Hook): if not exists(out): makedirs(out) - files_ids = [(save_join(dl, p.folder, x["name"]), x["id"]) for x in p.getChildren().itervalues()] + files_ids = [(save_join(dl, p.folder, x['name']), x['id']) for x in p.getChildren().itervalues()] matched = False # check as long there are unseen files @@ -307,15 +307,15 @@ class ExtractArchive(Hook): if not exists(f): continue try: - if self.config["permission"]["change_file"]: + if self.config['permission']['change_file']: if isfile(f): - chmod(f, int(self.config["permission"]["file"], 8)) + chmod(f, int(self.config['permission']['file'], 8)) elif isdir(f): - chmod(f, int(self.config["permission"]["folder"], 8)) + chmod(f, int(self.config['permission']['folder'], 8)) - if self.config["permission"]["change_dl"] and os.name != "nt": - uid = getpwnam(self.config["permission"]["user"])[2] - gid = getgrnam(self.config["permission"]["group"])[2] + if self.config['permission']['change_dl'] and os.name != "nt": + uid = getpwnam(self.config['permission']['user'])[2] + gid = getgrnam(self.config['permission']['group'])[2] chown(f, uid, gid) except Exception, e: self.logWarning(_("Setting User and Group failed"), e) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 7dbe835c7..9a9bab9b4 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -155,25 +155,25 @@ class IRCInterface(Thread, Hook): self.handle_events(msg) def handle_events(self, msg): - if not msg["origin"].split("!", 1)[0] in self.getConfig("owner").split(): + if not msg['origin'].split("!", 1)[0] in self.getConfig("owner").split(): return - if msg["target"].split("!", 1)[0] != self.getConfig("nick"): + if msg['target'].split("!", 1)[0] != self.getConfig("nick"): return - if msg["action"] != "PRIVMSG": + if msg['action'] != "PRIVMSG": return # HANDLE CTCP ANTI FLOOD/BOT PROTECTION - if msg["text"] == "\x01VERSION\x01": + if msg['text'] == "\x01VERSION\x01": self.logDebug("Sending CTCP VERSION.") self.sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface")) return - elif msg["text"] == "\x01TIME\x01": + elif msg['text'] == "\x01TIME\x01": self.logDebug("Sending CTCP TIME.") self.sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time())) return - elif msg["text"] == "\x01LAG\x01": + elif msg['text'] == "\x01LAG\x01": self.logDebug("Received CTCP LAG.") # don't know how to answer return @@ -181,7 +181,7 @@ class IRCInterface(Thread, Hook): args = None try: - temp = msg["text"].split() + temp = msg['text'].split() trigger = temp[0] if len(temp) > 1: args = temp[1:] @@ -192,7 +192,7 @@ class IRCInterface(Thread, Hook): try: res = handler(args) for line in res: - self.response(line, msg["origin"]) + self.response(line, msg['origin']) except Exception, e: self.logError("pyLoad IRC: " + repr(e)) @@ -258,7 +258,7 @@ class IRCInterface(Thread, Hook): def event_info(self, args): if not args: - return ['ERROR: Use info like this: info '] + return ["ERROR: Use info like this: info "] info = None try: @@ -271,7 +271,7 @@ class IRCInterface(Thread, Hook): def event_packinfo(self, args): if not args: - return ['ERROR: Use packinfo like this: packinfo '] + return ["ERROR: Use packinfo like this: packinfo "] lines = [] pack = None @@ -321,7 +321,7 @@ class IRCInterface(Thread, Hook): def event_add(self, args): if len(args) < 2: return ['ERROR: Add links like this: "add links". ', - 'This will add the link to to the package / the package with id !'] + "This will add the link to to the package / the package with id !"] pack = args[0].strip() links = [x.strip() for x in args[1:]] @@ -336,7 +336,7 @@ class IRCInterface(Thread, Hook): #TODO add links - return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack["name"], id)] + return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack['name'], id)] except: # create new package diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 794db3913..4d7be96e3 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -136,7 +136,7 @@ class ImageTyperz(Hook): if task.data['service'] == self.__name__ and "ticket" in task.data: response = getURL(self.RESPOND_URL, post={"action": "SETBADIMAGE", "username": self.getConfig("username"), "password": self.getConfig("passkey"), - "imageid": task.data["ticket"]}) + "imageid": task.data['ticket']}) if response == "SUCCESS": self.logInfo("Bad captcha solution received, requested refund") @@ -151,5 +151,5 @@ class ImageTyperz(Hook): task.error = e.getCode() return - task.data["ticket"] = ticket + task.data['ticket'] = ticket task.setResult(result) diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index 75995faf2..d6acac4a9 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -48,7 +48,7 @@ class LinkdecrypterCom(Hook): return builtin = [name.lower() for name in self.core.pluginManager.crypterPlugins.keys()] - builtin.extend(["downloadserienjunkiesorg"]) + builtin.append("downloadserienjunkiesorg") crypter_pattern = re.compile("(\w[\w.-]+)") online = [] @@ -64,7 +64,7 @@ class LinkdecrypterCom(Hook): regexp = r"https?://([^.]+\.)*?(%s)/.*" % "|".join(online) dict = self.core.pluginManager.crypterPlugins[self.__name__] - dict["pattern"] = regexp - dict["re"] = re.compile(regexp) + dict['pattern'] = regexp + dict['re'] = re.compile(regexp) self.logDebug("REGEXP: " + regexp) diff --git a/module/plugins/hooks/MegaDebridEu.py b/module/plugins/hooks/MegaDebridEu.py index 31be74fdd..22945cc0f 100644 --- a/module/plugins/hooks/MegaDebridEu.py +++ b/module/plugins/hooks/MegaDebridEu.py @@ -36,7 +36,7 @@ class MegaDebridEu(MultiHoster): reponse = getURL('http://www.mega-debrid.eu/api.php?action=getHosters') json_data = json_loads(reponse) - if json_data["response_code"] == "ok": + if json_data['response_code'] == "ok": host_list = [element[0] for element in json_data['hosters']] else: self.logError("Unable to retrieve hoster list") diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index e7bd63d17..5d6c208a7 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -47,12 +47,12 @@ class MergeFiles(Hook): files = {} fid_dict = {} for fid, data in pack.getChildren().iteritems(): - if re.search("\.[0-9]{3}$", data["name"]): - if data["name"][:-4] not in files: - files[data["name"][:-4]] = [] - files[data["name"][:-4]].append(data["name"]) - files[data["name"][:-4]].sort() - fid_dict[data["name"]] = fid + if re.search("\.[0-9]{3}$", data['name']): + if data['name'][:-4] not in files: + files[data['name'][:-4]] = [] + files[data['name'][:-4]].append(data['name']) + files[data['name'][:-4]].sort() + fid_dict[data['name']] = fid download_folder = self.config['general']['download_folder'] diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 31bbbcc9a..b9c663046 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -38,7 +38,7 @@ class MultiHome(Hook): self.interfaces = [] self.parseInterfaces(self.getConfig("interfaces").split(";")) if not self.interfaces: - self.parseInterfaces([self.config["download"]["interface"]]) + self.parseInterfaces([self.config['download']['interface']]) self.setConfig("interfaces", self.toConfig()) def toConfig(self): diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 0841e07a6..96e06950e 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -34,7 +34,7 @@ class RehostTo(MultiHoster): return data = self.account.getAccountInfo(user) - self.ses = data["ses"] - self.long_ses = data["long_ses"] + self.ses = data['ses'] + self.long_ses = data['long_ses'] return MultiHoster.coreReady(self) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 242659d9e..b6ba853a7 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -95,7 +95,7 @@ class UpdateManager(Hook): return True if self.core.pluginManager.reloadPlugins(reloads) else False def periodical(self): - if not self.info["pyload"] and not (self.getConfig("nodebugupdate") and self.core.debug): + if not self.info['pyload'] and not (self.getConfig("nodebugupdate") and self.core.debug): self.updating = True self.update(onlyplugin=True if self.getConfig("mode") == "plugins only" else False) self.updating = False @@ -127,15 +127,15 @@ class UpdateManager(Hook): newversion = data[0] self.logInfo(_("*** New pyLoad Version %s available ***") % newversion) self.logInfo(_("*** Get it here: https://github.com/pyload/pyload/releases ***")) - r = self.info["pyload"] = True - self.info["version"] = newversion + r = self.info['pyload'] = True + self.info['version'] = newversion return r @threaded def _updatePlugins(self, updates): """ check for plugin updates """ - if self.info["plugins"]: + if self.info['plugins']: return False #: plugins were already updated updated = [] @@ -152,9 +152,9 @@ class UpdateManager(Hook): data = sorted(map(lambda x: dict(zip(schema, x.split('|'))), updates), key=itemgetter("type", "name")) for plugin in data: - filename = plugin["name"] - prefix = plugin["type"] - version = plugin["version"] + filename = plugin['name'] + prefix = plugin['type'] + version = plugin['version'] if filename.endswith(".pyc"): name = filename[:filename.find("_")] @@ -169,7 +169,7 @@ class UpdateManager(Hook): plugins = getattr(self.core.pluginManager, "%sPlugins" % type) - oldver = float(plugins[name]["v"]) if name in plugins else None + oldver = float(plugins[name]['v']) if name in plugins else None newver = float(version) if not oldver: @@ -213,7 +213,7 @@ class UpdateManager(Hook): self.logInfo(_("Plugins updated and reloaded")) else: self.logInfo(_("*** Plugins have been updated, pyLoad will be restarted now ***")) - self.info["plugins"] = True + self.info['plugins'] = True self.scheduler.addJob(4, self.core.api.restart(), threaded=False) #: risky, but pyload doesn't let more return True else: diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 09d035e10..37a464b33 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -64,8 +64,8 @@ class XFileSharingPro(Hook): #self.logDebug(regexp) dict = self.core.pluginManager.hosterPlugins['XFileSharingPro'] - dict["pattern"] = regexp - dict["re"] = re.compile(regexp) + dict['pattern'] = regexp + dict['re'] = re.compile(regexp) self.logDebug("Pattern loaded - handling %d hosters" % len(hosterList)) def getConfigSet(self, option): @@ -74,5 +74,5 @@ class XFileSharingPro(Hook): def unload(self): dict = self.core.pluginManager.hosterPlugins['XFileSharingPro'] - dict["pattern"] = r"^unmatchable$" - dict["re"] = re.compile(r"^unmatchable$") + dict['pattern'] = r'^unmatchable$' + dict['re'] = re.compile(r'^unmatchable$') diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 57a997a4b..a60d31b89 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -121,9 +121,7 @@ class XMPPInterface(IRCInterface, JabberClient): The handlers returned will be called when matching message is received in a client session.""" - return [ - ("normal", self.message), - ] + return [("normal", self.message)] def message(self, stanza): """Message handler for the component.""" @@ -231,9 +229,7 @@ class VersionHandler(object): def get_iq_get_handlers(self): """Return list of tuples (element_name, namespace, handler) describing handlers of stanzas""" - return [ - ("query", "jabber:iq:version", self.get_version), - ] + return [("query", "jabber:iq:version", self.get_version)] def get_iq_set_handlers(self): """Return empty list, as this class provides no stanza handler.""" -- cgit v1.2.3 From 0ec49b88b61490f3247a87dd610547a5dd5eb121 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 01:36:58 +0200 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/687 --- module/plugins/hooks/UpdateManager.py | 84 ++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 35 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index b6ba853a7..e67a784bd 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -import sys import re +import sys from operator import itemgetter from os import remove, stat @@ -14,7 +14,7 @@ from module.plugins.Hook import Expose, Hook, threaded class UpdateManager(Hook): __name__ = "UpdateManager" - __version__ = "0.31" + __version__ = "0.32" __type__ = "hook" __config__ = [("activated", "bool", "Activated", True), @@ -27,11 +27,11 @@ class UpdateManager(Hook): __author_name__ = "Walter Purcaro" __author_mail__ = "vuolter@gmail.com" + event_list = ["pluginConfigChanged"] + SERVER_URL = "http://updatemanager.pyload.org" MIN_INTERVAL = 3 * 60 * 60 #: 3h minimum check interval (value is in seconds) - event_list = ["pluginConfigChanged"] - def pluginConfigChanged(self, plugin, name, value): if name == "interval": @@ -60,11 +60,10 @@ class UpdateManager(Hook): self.info = {"pyload": False, "version": None, "plugins": False} self.mtimes = {} #: store modification time for each plugin - def periodical2(self): if not self.updating: self.autoreloadPlugins() - self.cb2 = self.scheduler.addJob(10, self.periodical2, threaded=True) + self.cb2 = self.scheduler.addJob(4, self.periodical2, threaded=False) @Expose def autoreloadPlugins(self): @@ -72,7 +71,8 @@ class UpdateManager(Hook): modules = filter( lambda m: m and (m.__name__.startswith("module.plugins.") or m.__name__.startswith("userplugins.")) and - m.__name__.count(".") >= 2, sys.modules.itervalues()) + m.__name__.count(".") >= 2, sys.modules.itervalues() + ) reloads = [] @@ -96,16 +96,23 @@ class UpdateManager(Hook): def periodical(self): if not self.info['pyload'] and not (self.getConfig("nodebugupdate") and self.core.debug): - self.updating = True - self.update(onlyplugin=True if self.getConfig("mode") == "plugins only" else False) - self.updating = False + self.updateThread() - def server_response(self): + def server_request(self): try: return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() except: self.logWarning(_("Unable to contact server to get updates")) + @threaded + def updateThread(self): + self.updating = True + status = self.update(onlyplugin=True if self.getConfig("mode") == "plugins only" else False) + if status == 2: + self.core.api.restart() + else: + self.updating = False + @Expose def updatePlugins(self): """ simple wrapper for calling plugin update quickly """ @@ -114,24 +121,24 @@ class UpdateManager(Hook): @Expose def update(self, onlyplugin=False): """ check for updates """ - data = self.server_response() + data = self.server_request() if not data: - r = False + exitcode = 0 elif data[0] == "None": self.logInfo(_("No new pyLoad version available")) updates = data[1:] - r = self._updatePlugins(updates) + exitcode = self._updatePlugins(updates) elif onlyplugin: - r = False + exitcode = 0 else: newversion = data[0] self.logInfo(_("*** New pyLoad Version %s available ***") % newversion) self.logInfo(_("*** Get it here: https://github.com/pyload/pyload/releases ***")) - r = self.info['pyload'] = True + exitcode = 3 + self.info['pyload'] = True self.info['version'] = newversion - return r + return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required; 3 = No plugins updated, new pyLoad version available - @threaded def _updatePlugins(self, updates): """ check for plugin updates """ @@ -150,8 +157,8 @@ class UpdateManager(Hook): blacklist = None updates = updates[2:] - data = sorted(map(lambda x: dict(zip(schema, x.split('|'))), updates), key=itemgetter("type", "name")) - for plugin in data: + upgradable = sorted(map(lambda x: dict(zip(schema, x.split('|'))), updates), key=itemgetter("type", "name")) + for plugin in upgradable: filename = plugin['name'] prefix = plugin['type'] version = plugin['version'] @@ -200,9 +207,14 @@ class UpdateManager(Hook): self.logError(_("Error updating plugin %s") % filename, str(e)) if blacklist: - removed = self.removePlugins(map(lambda x: x.split('|'), blacklist)) + blacklisted = sorted(map(lambda x: x.split('|'), blacklist)) + for t, n in blacklisted: + if t == "hook": + self.manager.deactivateHook(n) + + removed = self.removePlugins(blacklisted) for t, n in removed: - self.logInfo(_("Removed blacklisted plugin: [%(type)s] %(name)s") % { + self.logInfo(_("Removed blacklisted plugin [%(type)s] %(name)s") % { "type": t, "name": n }) @@ -211,18 +223,21 @@ class UpdateManager(Hook): reloaded = self.core.pluginManager.reloadPlugins(updated) if reloaded: self.logInfo(_("Plugins updated and reloaded")) + exitcode = 1 else: - self.logInfo(_("*** Plugins have been updated, pyLoad will be restarted now ***")) + self.logInfo(_("*** Plugins have been updated, but need a pyLoad restart to be reloaded ***")) self.info['plugins'] = True - self.scheduler.addJob(4, self.core.api.restart(), threaded=False) #: risky, but pyload doesn't let more - return True + exitcode = 2 else: self.logInfo(_("No plugin updates available")) - return False + exitcode = 0 + + return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required @Expose def removePlugins(self, type_plugins): - """ delete plugins under userplugins directory""" + """ delete plugins from disk""" + if not type_plugins: return None @@ -231,17 +246,16 @@ class UpdateManager(Hook): removed = [] for type, name in type_plugins: - py = join("userplugins", type, name) - pyc = join("userplugins", type, name.replace('.py', '.pyc')) id = (type, name) + pyfile = join("userplugins", type, name) + pycfile = pyfile.replace(".py", ".pyc") try: - if isfile(py): - remove(py) - if isfile(pyc): - remove(pyc) + if isfile(pyfile): + remove(pyfile) + removed.append(id) + if isfile(pycfile): + remove(pycfile) except Exception, e: self.logError("Error deleting %s" % id, str(e)) - else: - removed.append(id) return removed #: return a list of the plugins successfully removed -- cgit v1.2.3 From 05d258d98dd8c2faf0b769840fa1e3c4acccdce8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:25:14 +0200 Subject: Fix and improve 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 --- module/plugins/hooks/DownloadScheduler.py | 2 +- module/plugins/hooks/IRCInterface.py | 5 +---- module/plugins/hooks/LinkdecrypterCom.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index dbc1019e3..070c0634e 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -43,7 +43,7 @@ class DownloadScheduler(Hook): self.updateSchedule() def updateSchedule(self, schedule=None): - if not schedule: + if schedule is None: schedule = self.getConfig("timetable") schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 9a9bab9b4..a29874469 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -59,12 +59,9 @@ class IRCInterface(Thread, Hook): self.api = core.api # todo, only use api def coreReady(self): - self.new_package = {} - self.abort = False - - self.links_added = 0 self.more = [] + self.new_package = {} self.start() diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index d6acac4a9..4e08372fe 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -43,7 +43,7 @@ class LinkdecrypterCom(Hook): def loadPatterns(self): page = getURL("http://linkdecrypter.com/") m = re.search(r'Supported\(\d+\): ([^+<]*)', page) - if not m: + if m is None: self.logError(_("Crypter list not found")) return -- cgit v1.2.3 From b5eda37f8b7e540ae6581fd612aa7e0ec7c1e9b2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:32:28 +0200 Subject: [UpdateManager] Rewritten removePlugins method + protect from self-removing --- module/plugins/hooks/UpdateManager.py | 58 +++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index e67a784bd..6ed756d13 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -5,16 +5,17 @@ import sys from operator import itemgetter from os import remove, stat -from os.path import join, isfile +from os.path import isfile from time import time from module.network.RequestFactory import getURL from module.plugins.Hook import Expose, Hook, threaded +from module.utils import save_join class UpdateManager(Hook): __name__ = "UpdateManager" - __version__ = "0.32" + __version__ = "0.33" __type__ = "hook" __config__ = [("activated", "bool", "Activated", True), @@ -63,7 +64,7 @@ class UpdateManager(Hook): def periodical2(self): if not self.updating: self.autoreloadPlugins() - self.cb2 = self.scheduler.addJob(4, self.periodical2, threaded=False) + self.cb2 = self.scheduler.addJob(10, self.periodical2, threaded=False) @Expose def autoreloadPlugins(self): @@ -197,7 +198,7 @@ class UpdateManager(Hook): content = getURL(url % plugin) m = vre.search(content) if m and m.group(2) == version: - f = open(join("userplugins", prefix, filename), "wb") + f = open(save_join("userplugins", prefix, filename), "wb") f.write(content) f.close() updated.append((prefix, name)) @@ -207,10 +208,13 @@ class UpdateManager(Hook): self.logError(_("Error updating plugin %s") % filename, str(e)) if blacklist: - blacklisted = sorted(map(lambda x: x.split('|'), blacklist)) - for t, n in blacklisted: - if t == "hook": - self.manager.deactivateHook(n) + blacklisted = sorted(map(lambda x: (x.split('|')[0], x.split('|')[1].rsplit('.', 1)[0]), blacklist)) + + # Always protect UpdateManager from self-removing + try: + blacklisted.remove(("hook", "UpdateManager")) + except: + pass removed = self.removePlugins(blacklisted) for t, n in removed: @@ -246,16 +250,32 @@ class UpdateManager(Hook): removed = [] for type, name in type_plugins: - id = (type, name) - pyfile = join("userplugins", type, name) - pycfile = pyfile.replace(".py", ".pyc") - try: - if isfile(pyfile): - remove(pyfile) - removed.append(id) - if isfile(pycfile): - remove(pycfile) - except Exception, e: - self.logError("Error deleting %s" % id, str(e)) + rflag = False + py_file = name + ".py" + pyc_file = name + ".pyc" + + for root in ("userplugins", save_join(pypath, "module", "plugins")): + py_filename = save_join(root, type, py_file) + pyc_filename = save_join(root, type, pyc_file) + + if isfile(py_filename): + try: + remove(py_filename) + except Exception, e: + self.logError("Error deleting file %s" % py_filename, str(e)) + rflag = False + else: + rflag = True + + if isfile(pyc_filename): + try: + if type == "hook": + self.manager.deactivateHook(name) + remove(pyc_filename) + except Exception, e: + self.logError("Error deleting file %s" % pyc_filename, str(e)) + if rflag: + id = (type, name) + removed.append(id) return removed #: return a list of the plugins successfully removed -- cgit v1.2.3 From 9395182da7afed55a29bde1c7cbefe4204e783f0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:02:09 +0200 Subject: Store all re.search/match object as "m" instead "found" --- module/plugins/hooks/EasybytezCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index 533301a4e..1cf5e40ae 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -27,8 +27,8 @@ class EasybytezCom(MultiHoster): req = self.account.getAccountRequest(user) page = req.load("http://www.easybytez.com") - found = re.search(r'\s*Supported sites:(.*)', page) - return found.group(1).split(',') + m = re.search(r'\s*Supported sites:(.*)', page) + return m.group(1).split(',') except Exception, e: self.logDebug(e) self.logWarning("Unable to load supported hoster list, using last known") -- cgit v1.2.3 From 77c7afff0fb6d89911a5ec2ca5751cdb266698db Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 17:01:16 +0200 Subject: [UpdateManager] Disable reloadplugins schedule on plugin deactivation --- module/plugins/hooks/UpdateManager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 6ed756d13..5f71ad6fa 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -15,8 +15,8 @@ from module.utils import save_join class UpdateManager(Hook): __name__ = "UpdateManager" - __version__ = "0.33" __type__ = "hook" + __version__ = "0.34" __config__ = [("activated", "bool", "Activated", True), ("mode", "pyLoad + plugins;plugins only", "Check updates for", "pyLoad + plugins"), @@ -53,6 +53,9 @@ class UpdateManager(Hook): self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig("reloadplugins")) + def unload(self): + self.pluginConfigChanged(self.__name__, "reloadplugins", False) + def setup(self): self.scheduler = self.core.scheduler self.cb2 = None @@ -181,7 +184,7 @@ class UpdateManager(Hook): newver = float(version) if not oldver: - msg = "New version of [%(type)s] %(name)s (v%(newver)s)" + msg = "New [%(type)s] %(name)s (v%(newver)s)" elif newver > oldver: msg = "New version of [%(type)s] %(name)s (v%(oldver)s -> v%(newver)s)" else: -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hooks/AlldebridCom.py | 4 +--- module/plugins/hooks/BypassCaptcha.py | 28 +++++------------------ module/plugins/hooks/Captcha9kw.py | 24 +++++--------------- module/plugins/hooks/CaptchaBrotherhood.py | 26 +++++---------------- module/plugins/hooks/Checksum.py | 23 +++++-------------- module/plugins/hooks/ClickAndLoad.py | 17 +------------- module/plugins/hooks/DeathByCaptcha.py | 29 +++++++----------------- module/plugins/hooks/DebridItaliaCom.py | 16 +------------ module/plugins/hooks/DeleteFinished.py | 17 +------------- module/plugins/hooks/DownloadScheduler.py | 18 ++------------- module/plugins/hooks/EasybytezCom.py | 2 +- module/plugins/hooks/Ev0InFetcher.py | 17 ++------------ module/plugins/hooks/ExpertDecoders.py | 23 ++++--------------- module/plugins/hooks/ExternalScripts.py | 18 ++------------- module/plugins/hooks/ExtractArchive.py | 21 +++++++++-------- module/plugins/hooks/FastixRu.py | 6 ++--- module/plugins/hooks/FreeWayMe.py | 17 +------------- module/plugins/hooks/HotFolder.py | 27 +++++----------------- module/plugins/hooks/IRCInterface.py | 28 ++++++----------------- module/plugins/hooks/ImageTyperz.py | 24 +++++--------------- module/plugins/hooks/LinkdecrypterCom.py | 19 ++-------------- module/plugins/hooks/LinksnappyCom.py | 6 ++--- module/plugins/hooks/MegaDebridEu.py | 20 +++-------------- module/plugins/hooks/MergeFiles.py | 30 ++++++------------------- module/plugins/hooks/MultiDebridCom.py | 20 +++-------------- module/plugins/hooks/MultiHome.py | 17 +------------- module/plugins/hooks/MultishareCz.py | 2 +- module/plugins/hooks/OverLoadMe.py | 2 +- module/plugins/hooks/Premium4Me.py | 2 +- module/plugins/hooks/PremiumizeMe.py | 9 ++++---- module/plugins/hooks/RPNetBiz.py | 8 +++---- module/plugins/hooks/RealdebridCom.py | 2 +- module/plugins/hooks/RehostTo.py | 2 +- module/plugins/hooks/RestartFailed.py | 16 +------------ module/plugins/hooks/SimplyPremiumCom.py | 16 +------------ module/plugins/hooks/SimplydebridCom.py | 2 +- module/plugins/hooks/UnSkipOnFail.py | 20 +++-------------- module/plugins/hooks/UnrestrictLi.py | 20 +++-------------- module/plugins/hooks/UpdateManager.py | 4 ++-- module/plugins/hooks/WindowsPhoneToastNotify.py | 19 +++------------- module/plugins/hooks/XFileSharingPro.py | 2 +- module/plugins/hooks/XMPPInterface.py | 19 ++-------------- module/plugins/hooks/ZeveraCom.py | 2 +- 43 files changed, 126 insertions(+), 518 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index 1ef9b252a..906875a69 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -1,15 +1,13 @@ # -*- coding: utf-8 -*- -# should be working - from module.network.RequestFactory import getURL from module.plugins.internal.MultiHoster import MultiHoster class AlldebridCom(MultiHoster): __name__ = "AlldebridCom" - __version__ = "0.13" __type__ = "hook" + __version__ = "0.13" __config__ = [("activated", "bool", "Activated", False), ("https", "bool", "Enable HTTPS", False), diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 5ac117818..d62de24a7 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -1,30 +1,12 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - -from thread import start_new_thread from pycurl import FORM_FILE, LOW_SPEED_TIME +from thread import start_new_thread -from module.network.RequestFactory import getURL, getRequest from module.network.HTTPRequest import BadHeader - +from module.network.RequestFactory import getURL, getRequest from module.plugins.Hook import Hook -PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32" - class BypassCaptchaException(Exception): @@ -43,8 +25,8 @@ class BypassCaptchaException(Exception): class BypassCaptcha(Hook): __name__ = "BypassCaptcha" - __version__ = "0.04" __type__ = "hook" + __version__ = "0.04" __config__ = [("activated", "bool", "Activated", False), ("force", "bool", "Force BC even if client is connected", False), @@ -54,6 +36,8 @@ class BypassCaptcha(Hook): __author_name__ = ("RaNaN", "Godofdream", "zoidberg") __author_mail__ = ("RaNaN@pyload.org", "soilfcition@gmail.com", "zoidberg@mujmail.cz") + PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32" + SUBMIT_URL = "http://bypasscaptcha.com/upload.php" RESPOND_URL = "http://bypasscaptcha.com/check_value.php" GETCREDITS_URL = "http://bypasscaptcha.com/ex_left.php" @@ -76,7 +60,7 @@ class BypassCaptcha(Hook): try: response = req.load(self.SUBMIT_URL, - post={"vendor_key": PYLOAD_KEY, + post={"vendor_key": self.PYLOAD_KEY, "key": self.getConfig("passkey"), "gen_task_id": "1", "file": (FORM_FILE, captcha)}, diff --git a/module/plugins/hooks/Captcha9kw.py b/module/plugins/hooks/Captcha9kw.py index b4e3ad34b..1b7406edd 100755 --- a/module/plugins/hooks/Captcha9kw.py +++ b/module/plugins/hooks/Captcha9kw.py @@ -1,35 +1,21 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" from __future__ import with_statement -from thread import start_new_thread -from base64 import b64encode import time -from module.network.RequestFactory import getURL -from module.network.HTTPRequest import BadHeader +from base64 import b64encode +from thread import start_new_thread +from module.network.HTTPRequest import BadHeader +from module.network.RequestFactory import getURL from module.plugins.Hook import Hook class Captcha9kw(Hook): __name__ = "Captcha9kw" - __version__ = "0.09" __type__ = "hook" + __version__ = "0.09" __config__ = [("activated", "bool", "Activated", False), ("force", "bool", "Force CT even if client is connected", True), diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 54dfbe4d6..e240cbbc0 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -1,28 +1,14 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" from __future__ import with_statement -from thread import start_new_thread - -import pycurl import StringIO -from urllib import urlencode -from time import sleep +import pycurl + from PIL import Image +from thread import start_new_thread +from time import sleep +from urllib import urlencode from module.network.RequestFactory import getURL, getRequest from module.plugins.Hook import Hook @@ -45,8 +31,8 @@ class CaptchaBrotherhoodException(Exception): class CaptchaBrotherhood(Hook): __name__ = "CaptchaBrotherhood" - __version__ = "0.05" __type__ = "hook" + __version__ = "0.05" __config__ = [("activated", "bool", "Activated", False), ("username", "str", "Username", ""), diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index a51eb4b47..0fe2ae88c 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -1,29 +1,16 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - from __future__ import with_statement + import hashlib +import re import zlib + from os import remove from os.path import getsize, isfile, splitext -import re -from module.utils import save_join, fs_encode from module.plugins.Hook import Hook +from module.utils import save_join, fs_encode def computeChecksum(local_file, algorithm): @@ -52,8 +39,8 @@ def computeChecksum(local_file, algorithm): class Checksum(Hook): __name__ = "Checksum" - __version__ = "0.12" __type__ = "hook" + __version__ = "0.12" __config__ = [("activated", "bool", "Activated", False), ("check_action", "fail;retry;nothing", "What to do if check fails?", "retry"), diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 3c47d30ce..5c523caf7 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -1,20 +1,5 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - import socket import thread @@ -23,8 +8,8 @@ from module.plugins.Hook import Hook class ClickAndLoad(Hook): __name__ = "ClickAndLoad" - __version__ = "0.22" __type__ = "hook" + __version__ = "0.22" __config__ = [("activated", "bool", "Activated", True), ("extern", "bool", "Allow external link adding", False)] diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 64ed2280f..530395d32 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -1,31 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" from __future__ import with_statement -from thread import start_new_thread +import re + +from base64 import b64encode from pycurl import FORM_FILE, HTTPHEADER +from thread import start_new_thread from time import sleep -from base64 import b64encode -import re -from module.network.RequestFactory import getRequest +from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader +from module.network.RequestFactory import getRequest from module.plugins.Hook import Hook -from module.common.json_layer import json_loads class DeathByCaptchaException(Exception): @@ -59,8 +46,8 @@ class DeathByCaptchaException(Exception): class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" - __version__ = "0.03" __type__ = "hook" + __version__ = "0.03" __config__ = [("activated", "bool", "Activated", False), ("username", "str", "Username", ""), @@ -134,7 +121,7 @@ class DeathByCaptcha(Hook): raise DeathByCaptchaException('service-overload') def submit(self, captcha, captchaType="file", match=None): - #workaround multipart-post bug in HTTPRequest.py + #workaround multipart-post bug in HTTPRequest.py if re.match("^[A-Za-z0-9]*$", self.getConfig("passkey")): multipart = True data = (FORM_FILE, captcha) diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py index 1a081da7a..88efb6b2a 100644 --- a/module/plugins/hooks/DebridItaliaCom.py +++ b/module/plugins/hooks/DebridItaliaCom.py @@ -1,26 +1,12 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see . # -############################################################################ from module.plugins.internal.MultiHoster import MultiHoster class DebridItaliaCom(MultiHoster): __name__ = "DebridItaliaCom" - __version__ = "0.07" __type__ = "hook" + __version__ = "0.07" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 1c80facc9..bc926906f 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -1,28 +1,13 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - from module.database import style from module.plugins.Hook import Hook class DeleteFinished(Hook): __name__ = "DeleteFinished" - __version__ = "1.09" __type__ = "hook" + __version__ = "1.09" __config__ = [('activated', 'bool', 'Activated', 'False'), ('interval', 'int', 'Delete every (hours)', '72'), diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 070c0634e..a3d70b3ab 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -1,21 +1,7 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - You should have received a copy of the GNU General Public License - along with this program; if not, see . - - Original idea by new.cze -""" - import re + from time import localtime from module.plugins.Hook import Hook @@ -23,8 +9,8 @@ from module.plugins.Hook import Hook class DownloadScheduler(Hook): __name__ = "DownloadScheduler" - __version__ = "0.21" __type__ = "hook" + __version__ = "0.21" __config__ = [("activated", "bool", "Activated", False), ("timetable", "str", "List time periods as hh:mm full or number(kB/s)", diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index 1cf5e40ae..da37297d9 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -7,8 +7,8 @@ from module.plugins.internal.MultiHoster import MultiHoster class EasybytezCom(MultiHoster): __name__ = "EasybytezCom" - __version__ = "0.03" __type__ = "hook" + __version__ = "0.03" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/Ev0InFetcher.py b/module/plugins/hooks/Ev0InFetcher.py index 3a98abbf7..c54c38bc6 100644 --- a/module/plugins/hooks/Ev0InFetcher.py +++ b/module/plugins/hooks/Ev0InFetcher.py @@ -1,29 +1,16 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" from time import mktime, time from module.lib import feedparser + from module.plugins.Hook import Hook class Ev0InFetcher(Hook): __name__ = "Ev0InFetcher" - __version__ = "0.21" __type__ = "hook" + __version__ = "0.21" __config__ = [("activated", "bool", "Activated", False), ("interval", "int", "Check interval in minutes", 10), diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index 9e151f8f6..c7ab80da0 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -1,36 +1,21 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" from __future__ import with_statement -from thread import start_new_thread +from base64 import b64encode from pycurl import LOW_SPEED_TIME +from thread import start_new_thread from uuid import uuid4 -from base64 import b64encode -from module.network.RequestFactory import getURL, getRequest from module.network.HTTPRequest import BadHeader - +from module.network.RequestFactory import getURL, getRequest from module.plugins.Hook import Hook class ExpertDecoders(Hook): __name__ = "ExpertDecoders" - __version__ = "0.01" __type__ = "hook" + __version__ = "0.01" __config__ = [("activated", "bool", "Activated", False), ("force", "bool", "Force CT even if client is connected", False), diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 7f76df1cd..8d03d27d4 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -1,21 +1,7 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - import subprocess + from os import listdir, access, X_OK, makedirs from os.path import join, exists, basename, abspath @@ -25,8 +11,8 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" - __version__ = "0.23" __type__ = "hook" + __version__ = "0.23" __config__ = [("activated", "bool", "Activated", True)] diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c307deb8f..144829459 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -1,19 +1,18 @@ # -*- coding: utf-8 -*- -import sys import os +import sys + +from copy import copy from os import remove, chmod, makedirs -from os.path import exists, basename, isfile, isdir, join +from os.path import exists, basename, isfile, isdir from traceback import print_exc -from copy import copy # monkey patch bug in python 2.6 and lower -# see http://bugs.python.org/issue6122 -# http://bugs.python.org/issue1236 -# http://bugs.python.org/issue1731717 +# http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717 if sys.version_info < (2, 7) and os.name != "nt": - from subprocess import Popen import errno + from subprocess import Popen def _eintr_retry_call(func, *args): while True: @@ -44,13 +43,13 @@ if sys.version_info < (2, 7) and os.name != "nt": Popen.wait = wait if os.name != "nt": + from grp import getgrnam from os import chown 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 module.utils import save_join, fs_encode class ExtractArchive(Hook): @@ -58,8 +57,8 @@ class ExtractArchive(Hook): Provides: unrarFinished (folder, filename) """ __name__ = "ExtractArchive" - __version__ = "0.16" __type__ = "hook" + __version__ = "0.16" __config__ = [("activated", "bool", "Activated", True), ("fullpath", "bool", "Extract full path", True), @@ -158,7 +157,7 @@ class ExtractArchive(Hook): #relative to package folder if destination is relative, otherwise absolute path overwrites them if self.getConfig("subfolder"): - out = join(out, fs_encode(p.folder)) + out = save_join(out, fs_encode(p.folder)) if not exists(out): makedirs(out) diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py index aa020ea37..879dba277 100644 --- a/module/plugins/hooks/FastixRu.py +++ b/module/plugins/hooks/FastixRu.py @@ -1,16 +1,14 @@ # -*- coding: utf-8 -*- -# should be working - +from module.common.json_layer import json_loads from module.network.RequestFactory import getURL from module.plugins.internal.MultiHoster import MultiHoster -from module.common.json_layer import json_loads class FastixRu(MultiHoster): __name__ = "FastixRu" - __version__ = "0.02" __type__ = "hook" + __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index 3d2f7fcef..12d58ac8a 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -1,28 +1,13 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - from module.network.RequestFactory import getURL from module.plugins.internal.MultiHoster import MultiHoster class FreeWayMe(MultiHoster): __name__ = "FreeWayMe" - __version__ = "0.11" __type__ = "hook" + __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 08ef93812..4c81292e3 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -1,35 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - -from os import makedirs -from os import listdir -from os.path import exists -from os.path import join -from os.path import isfile -from shutil import move import time +from os import listdir, makedirs +from os.path import exists, isfile, join +from shutil import move + from module.plugins.Hook import Hook class HotFolder(Hook): __name__ = "HotFolder" - __version__ = "0.11" __type__ = "hook" + __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), ("folder", "str", "Folder to observe", "container"), diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index a29874469..7ebc0275f 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -1,39 +1,25 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" +import re +import socket +import time +from pycurl import FORM_FILE from select import select -import socket from threading import Thread -import time from time import sleep from traceback import print_exc -import re -from pycurl import FORM_FILE -from module.plugins.Hook import Hook +from module.Api import PackageDoesNotExists, FileDoesNotExists from module.network.RequestFactory import getURL +from module.plugins.Hook import Hook from module.utils import formatSize -from module.Api import PackageDoesNotExists, FileDoesNotExists class IRCInterface(Thread, Hook): __name__ = "IRCInterface" - __version__ = "0.11" __type__ = "hook" + __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), ("host", "str", "IRC-Server Address", "Enter your server here!"), diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 4d7be96e3..d9d4e547e 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -1,24 +1,12 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" from __future__ import with_statement -from thread import start_new_thread -from pycurl import FORM_FILE, LOW_SPEED_TIME + import re + from base64 import b64encode +from pycurl import FORM_FILE, LOW_SPEED_TIME +from thread import start_new_thread from module.network.RequestFactory import getURL, getRequest from module.plugins.Hook import Hook @@ -41,8 +29,8 @@ class ImageTyperzException(Exception): class ImageTyperz(Hook): __name__ = "ImageTyperz" - __version__ = "0.04" __type__ = "hook" + __version__ = "0.04" __config__ = [("activated", "bool", "Activated", False), ("username", "str", "Username", ""), @@ -82,7 +70,7 @@ class ImageTyperz(Hook): req.c.setopt(LOW_SPEED_TIME, 80) try: - #workaround multipart-post bug in HTTPRequest.py + #workaround multipart-post bug in HTTPRequest.py if re.match("^[A-Za-z0-9]*$", self.getConfig("passkey")): multipart = True data = (FORM_FILE, captcha) diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index 4e08372fe..1aa8f7ca1 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -1,31 +1,16 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - import re -from module.plugins.Hook import Hook from module.network.RequestFactory import getURL +from module.plugins.Hook import Hook from module.utils import remove_chars class LinkdecrypterCom(Hook): __name__ = "LinkdecrypterCom" - __version__ = "0.19" __type__ = "hook" + __version__ = "0.19" __config__ = [("activated", "bool", "Activated", False)] diff --git a/module/plugins/hooks/LinksnappyCom.py b/module/plugins/hooks/LinksnappyCom.py index a0e5b8d38..20da68632 100644 --- a/module/plugins/hooks/LinksnappyCom.py +++ b/module/plugins/hooks/LinksnappyCom.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.MultiHoster import MultiHoster -from module.network.RequestFactory import getURL from module.common.json_layer import json_loads +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster class LinksnappyCom(MultiHoster): __name__ = "LinksnappyCom" - __version__ = "0.01" __type__ = "hook" + __version__ = "0.01" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/MegaDebridEu.py b/module/plugins/hooks/MegaDebridEu.py index 22945cc0f..605b04f21 100644 --- a/module/plugins/hooks/MegaDebridEu.py +++ b/module/plugins/hooks/MegaDebridEu.py @@ -1,28 +1,14 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see . # -############################################################################ -from module.plugins.internal.MultiHoster import MultiHoster -from module.network.RequestFactory import getURL from module.common.json_layer import json_loads +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster class MegaDebridEu(MultiHoster): __name__ = "MegaDebridEu" - __version__ = "0.02" __type__ = "hook" + __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), ("unloadFailing", "bool", "Revert to standard download if download fails", False)] diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 5d6c208a7..a859092fb 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -1,35 +1,17 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - import os import re import traceback -from os.path import join -from module.utils import save_join, fs_encode from module.plugins.Hook import Hook, threaded - -BUFFER_SIZE = 4096 +from module.utils import save_join, fs_encode class MergeFiles(Hook): __name__ = "MergeFiles" - __version__ = "0.12" __type__ = "hook" + __version__ = "0.12" __config__ = [("activated", "bool", "Activated", False)] @@ -37,6 +19,8 @@ class MergeFiles(Hook): __author_name__ = "and9000" __author_mail__ = "me@has-no-mail.com" + BUFFER_SIZE = 4096 + def setup(self): # nothing to do @@ -61,7 +45,7 @@ class MergeFiles(Hook): for name, file_list in files.iteritems(): self.logInfo("Starting merging of %s" % name) - final_file = open(join(download_folder, fs_encode(name)), "wb") + final_file = open(save_join(download_folder, name), "wb") for splitted_file in file_list: self.logDebug("Merging part %s" % splitted_file) @@ -72,10 +56,10 @@ class MergeFiles(Hook): size_written = 0 s_file_size = int(os.path.getsize(os.path.join(download_folder, splitted_file))) while True: - f_buffer = s_file.read(BUFFER_SIZE) + f_buffer = s_file.read(self.BUFFER_SIZE) if f_buffer: final_file.write(f_buffer) - size_written += BUFFER_SIZE + size_written += self.BUFFER_SIZE pyfile.setProgress((size_written * 100) / s_file_size) else: break diff --git a/module/plugins/hooks/MultiDebridCom.py b/module/plugins/hooks/MultiDebridCom.py index 3309fb9a8..c5d1464f8 100644 --- a/module/plugins/hooks/MultiDebridCom.py +++ b/module/plugins/hooks/MultiDebridCom.py @@ -1,28 +1,14 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see . # -############################################################################ -from module.plugins.internal.MultiHoster import MultiHoster -from module.network.RequestFactory import getURL from module.common.json_layer import json_loads +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster class MultiDebridCom(MultiHoster): __name__ = "MultiDebridCom" - __version__ = "0.01" __type__ = "hook" + __version__ = "0.01" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index b9c663046..e2167b65e 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -1,20 +1,5 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - from time import time from module.plugins.Hook import Hook @@ -22,8 +7,8 @@ from module.plugins.Hook import Hook class MultiHome(Hook): __name__ = "MultiHome" - __version__ = "0.11" __type__ = "hook" + __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), ("interfaces", "str", "Interfaces", "None")] diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py index 8baa4bb07..9249106d6 100644 --- a/module/plugins/hooks/MultishareCz.py +++ b/module/plugins/hooks/MultishareCz.py @@ -8,8 +8,8 @@ from module.plugins.internal.MultiHoster import MultiHoster class MultishareCz(MultiHoster): __name__ = "MultishareCz" - __version__ = "0.04" __type__ = "hook" + __version__ = "0.04" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index dcc57aa75..5be0b8482 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -6,8 +6,8 @@ from module.plugins.internal.MultiHoster import MultiHoster class OverLoadMe(MultiHoster): __name__ = "OverLoadMe" - __version__ = "0.01" __type__ = "hook" + __version__ = "0.01" __config__ = [("activated", "bool", "Activated", False), ("https", "bool", "Enable HTTPS", True), diff --git a/module/plugins/hooks/Premium4Me.py b/module/plugins/hooks/Premium4Me.py index 242e72f3e..9c6701b06 100644 --- a/module/plugins/hooks/Premium4Me.py +++ b/module/plugins/hooks/Premium4Me.py @@ -6,8 +6,8 @@ from module.plugins.internal.MultiHoster import MultiHoster class Premium4Me(MultiHoster): __name__ = "Premium4Me" - __version__ = "0.03" __type__ = "hook" + __version__ = "0.03" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py index 1a35460de..e7291ece9 100644 --- a/module/plugins/hooks/PremiumizeMe.py +++ b/module/plugins/hooks/PremiumizeMe.py @@ -1,15 +1,14 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.MultiHoster import MultiHoster - from module.common.json_layer import json_loads from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster class PremiumizeMe(MultiHoster): __name__ = "PremiumizeMe" - __version__ = "0.12" __type__ = "hook" + __version__ = "0.12" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), @@ -40,7 +39,7 @@ class PremiumizeMe(MultiHoster): if data['status'] != 200: return [] - # Extract hosters from json file + # Extract hosters from json file return data['result']['hosterlist'] def coreReady(self): @@ -51,5 +50,5 @@ class PremiumizeMe(MultiHoster): self.logError(_("Please add a valid premiumize.me account first and restart pyLoad.")) return - # Run the overwriten core ready which actually enables the multihoster hook + # Run the overwriten core ready which actually enables the multihoster hook return MultiHoster.coreReady(self) diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py index 36cf69b4b..9b9b7cda9 100644 --- a/module/plugins/hooks/RPNetBiz.py +++ b/module/plugins/hooks/RPNetBiz.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.MultiHoster import MultiHoster from module.common.json_layer import json_loads from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster class RPNetBiz(MultiHoster): __name__ = "RPNetBiz" - __version__ = "0.1" __type__ = "hook" + __version__ = "0.1" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), @@ -37,7 +37,7 @@ class RPNetBiz(MultiHoster): if 'error' in hoster_list: return [] - # Extract hosters from json file + # Extract hosters from json file return hoster_list['hosters'] def coreReady(self): @@ -48,5 +48,5 @@ class RPNetBiz(MultiHoster): self.logError(_("Please enter your %s account or deactivate this plugin") % "rpnet") return - # Run the overwriten core ready which actually enables the multihoster hook + # Run the overwriten core ready which actually enables the multihoster hook return MultiHoster.coreReady(self) diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index 4477fba4a..87902ac7f 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -6,8 +6,8 @@ from module.plugins.internal.MultiHoster import MultiHoster class RealdebridCom(MultiHoster): __name__ = "RealdebridCom" - __version__ = "0.43" __type__ = "hook" + __version__ = "0.43" __config__ = [("activated", "bool", "Activated", False), ("https", "bool", "Enable HTTPS", False), diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 96e06950e..d504bb83b 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -6,8 +6,8 @@ from module.plugins.internal.MultiHoster import MultiHoster class RehostTo(MultiHoster): __name__ = "RehostTo" - __version__ = "0.43" __type__ = "hook" + __version__ = "0.43" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 2bd0e28db..3aef6f8cd 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -1,26 +1,12 @@ # -*- coding: utf-8 -*- -############################################################################### -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -############################################################################### from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" - __version__ = "1.55" __type__ = "hook" + __version__ = "1.55" __config__ = [("activated", "bool", "Activated", False), ("interval", "int", "Check interval in minutes", 90)] diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py index 41268e231..a946d391e 100644 --- a/module/plugins/hooks/SimplyPremiumCom.py +++ b/module/plugins/hooks/SimplyPremiumCom.py @@ -1,18 +1,4 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see . # -############################################################################ from module.common.json_layer import json_loads from module.network.RequestFactory import getURL @@ -21,8 +7,8 @@ from module.plugins.internal.MultiHoster import MultiHoster class SimplyPremiumCom(MultiHoster): __name__ = "SimplyPremiumCom" - __version__ = "0.02" __type__ = "hook" + __version__ = "0.02" __config__ = [("activated", "bool", "Activated", "False"), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py index 345d37e4a..ab13f312e 100644 --- a/module/plugins/hooks/SimplydebridCom.py +++ b/module/plugins/hooks/SimplydebridCom.py @@ -6,8 +6,8 @@ from module.plugins.internal.MultiHoster import MultiHoster class SimplydebridCom(MultiHoster): __name__ = "SimplydebridCom" - __version__ = "0.01" __type__ = "hook" + __version__ = "0.01" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index d40854e99..f25c5e2b4 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -1,30 +1,16 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" from os.path import basename -from module.utils import fs_encode -from module.plugins.Hook import Hook from module.PyFile import PyFile +from module.plugins.Hook import Hook +from module.utils import fs_encode class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" - __version__ = "0.01" __type__ = "hook" + __version__ = "0.01" __config__ = [("activated", "bool", "Activated", True)] diff --git a/module/plugins/hooks/UnrestrictLi.py b/module/plugins/hooks/UnrestrictLi.py index 3303c7355..ee5d79269 100644 --- a/module/plugins/hooks/UnrestrictLi.py +++ b/module/plugins/hooks/UnrestrictLi.py @@ -1,28 +1,14 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see . # -############################################################################ -from module.plugins.internal.MultiHoster import MultiHoster -from module.network.RequestFactory import getURL from module.common.json_layer import json_loads +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" - __version__ = "0.02" __type__ = "hook" + __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 5f71ad6fa..9e01989d9 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -5,7 +5,7 @@ import sys from operator import itemgetter from os import remove, stat -from os.path import isfile +from os.path import isfile, join from time import time from module.network.RequestFactory import getURL @@ -257,7 +257,7 @@ class UpdateManager(Hook): py_file = name + ".py" pyc_file = name + ".pyc" - for root in ("userplugins", save_join(pypath, "module", "plugins")): + for root in ("userplugins", join(pypath, "module", "plugins")): py_filename = save_join(root, type, py_file) pyc_filename = save_join(root, type, pyc_file) diff --git a/module/plugins/hooks/WindowsPhoneToastNotify.py b/module/plugins/hooks/WindowsPhoneToastNotify.py index 25fa3abe5..01570b966 100644 --- a/module/plugins/hooks/WindowsPhoneToastNotify.py +++ b/module/plugins/hooks/WindowsPhoneToastNotify.py @@ -1,28 +1,15 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" -import time import httplib +import time + from module.plugins.Hook import Hook class WindowsPhoneToastNotify(Hook): __name__ = "WindowsPhoneToastNotify" - __version__ = "0.02" __type__ = "hook" + __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), ("force", "bool", "Force even if client is connected", False), diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 37a464b33..eb0376921 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -7,8 +7,8 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" - __version__ = "0.11" __type__ = "hook" + __version__ = "0.11" __config__ = [("activated", "bool", "Activated", True), ("loadDefault", "bool", "Include default (built-in) hoster list", True), diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index a60d31b89..c4a94a8bc 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -1,33 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - from pyxmpp import streamtls from pyxmpp.all import JID, Message -from pyxmpp.jabber.client import JabberClient from pyxmpp.interface import implements from pyxmpp.interfaces import * +from pyxmpp.jabber.client import JabberClient from module.plugins.hooks.IRCInterface import IRCInterface class XMPPInterface(IRCInterface, JabberClient): __name__ = "XMPPInterface" - __version__ = "0.11" __type__ = "hook" + __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), ("jid", "str", "Jabber ID", "user@exmaple-jabber-server.org"), diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index 49fc68b30..0d5e23118 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -6,8 +6,8 @@ from module.plugins.internal.MultiHoster import MultiHoster class ZeveraCom(MultiHoster): __name__ = "ZeveraCom" - __version__ = "0.02" __type__ = "hook" + __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), -- cgit v1.2.3 From cb4f7ffd4d638d42a931349a171ba28aab17be97 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 30 Aug 2014 00:41:23 +0200 Subject: UpdateManager] Fix I/O conflict on activation + fix removePlugins + some code cosmetics --- module/plugins/hooks/UpdateManager.py | 79 +++++++++++++++++------------------ 1 file changed, 38 insertions(+), 41 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 9e01989d9..546e6e6e8 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -4,9 +4,7 @@ import re import sys from operator import itemgetter -from os import remove, stat -from os.path import isfile, join -from time import time +from os import path, remove, stat from module.network.RequestFactory import getURL from module.plugins.Hook import Expose, Hook, threaded @@ -16,7 +14,7 @@ from module.utils import save_join class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.34" + __version__ = "0.35" __config__ = [("activated", "bool", "Activated", True), ("mode", "pyLoad + plugins;plugins only", "Check updates for", "pyLoad + plugins"), @@ -24,10 +22,11 @@ class UpdateManager(Hook): ("reloadplugins", "bool", "Monitor plugins for code changes (debug mode only)", True), ("nodebugupdate", "bool", "Don't check for updates in debug mode", True)] - __description__ = """Check for updates""" + __description__ = """ Check for updates """ __author_name__ = "Walter Purcaro" __author_mail__ = "vuolter@gmail.com" + event_list = ["pluginConfigChanged"] SERVER_URL = "http://updatemanager.pyload.org" @@ -38,36 +37,36 @@ class UpdateManager(Hook): if name == "interval": interval = value * 60 * 60 if self.MIN_INTERVAL <= interval != self.interval: - self.scheduler.removeJob(self.cb) + self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() else: self.logDebug("Invalid interval value, kept current") elif name == "reloadplugins": if self.cb2: - self.scheduler.removeJob(self.cb2) + self.core.scheduler.removeJob(self.cb2) if value is True and self.core.debug: self.periodical2() def coreReady(self): self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) - self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig("reloadplugins")) + x = lambda: self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig("reloadplugins")) + self.core.scheduler.addJob(10, x, threaded=False) def unload(self): self.pluginConfigChanged(self.__name__, "reloadplugins", False) def setup(self): - self.scheduler = self.core.scheduler self.cb2 = None self.interval = self.MIN_INTERVAL self.updating = False - self.info = {"pyload": False, "version": None, "plugins": False} + self.info = {'pyload': False, 'version': None, 'plugins': False} self.mtimes = {} #: store modification time for each plugin def periodical2(self): if not self.updating: self.autoreloadPlugins() - self.cb2 = self.scheduler.addJob(10, self.periodical2, threaded=False) + self.cb2 = self.core.scheduler.addJob(4, self.periodical2, threaded=False) @Expose def autoreloadPlugins(self): @@ -85,7 +84,7 @@ class UpdateManager(Hook): id = (type, name) if type in self.core.pluginManager.plugins: f = m.__file__.replace(".pyc", ".py") - if not isfile(f): + if not path.isfile(f): continue mtime = stat(f).st_mtime @@ -111,7 +110,7 @@ class UpdateManager(Hook): @threaded def updateThread(self): self.updating = True - status = self.update(onlyplugin=True if self.getConfig("mode") == "plugins only" else False) + status = self.update(onlyplugin=self.getConfig("mode") == "plugins only") if status == 2: self.core.api.restart() else: @@ -172,7 +171,7 @@ class UpdateManager(Hook): else: name = filename.replace(".py", "") - #TODO: obsolete in 0.5.0 + #@TODO: obsolete after 0.4.10 if prefix.endswith("s"): type = prefix[:-1] else: @@ -191,10 +190,10 @@ class UpdateManager(Hook): continue self.logInfo(_(msg) % { - "type": type, - "name": name, - "oldver": oldver, - "newver": newver + 'type': type, + 'name': name, + 'oldver': oldver, + 'newver': newver, }) try: @@ -206,7 +205,7 @@ class UpdateManager(Hook): f.close() updated.append((prefix, name)) else: - raise Exception(_("Version mismatch")) + raise Exception, _("Version mismatch") except Exception, e: self.logError(_("Error updating plugin %s") % filename, str(e)) @@ -222,8 +221,8 @@ class UpdateManager(Hook): removed = self.removePlugins(blacklisted) for t, n in removed: self.logInfo(_("Removed blacklisted plugin [%(type)s] %(name)s") % { - "type": t, - "name": n + 'type': t, + 'name': n, }) if updated: @@ -243,41 +242,39 @@ class UpdateManager(Hook): @Expose def removePlugins(self, type_plugins): - """ delete plugins from disk""" + """ delete plugins from disk """ if not type_plugins: - return None + return self.logDebug("Request deletion of plugins: %s" % type_plugins) removed = [] for type, name in type_plugins: - rflag = False - py_file = name + ".py" - pyc_file = name + ".pyc" + err = False + file = name + ".py" - for root in ("userplugins", join(pypath, "module", "plugins")): - py_filename = save_join(root, type, py_file) - pyc_filename = save_join(root, type, pyc_file) + for root in ("userplugins", path.join(pypath, "module", "plugins")): - if isfile(py_filename): - try: - remove(py_filename) - except Exception, e: - self.logError("Error deleting file %s" % py_filename, str(e)) - rflag = False - else: - rflag = True + filename = save_join(root, type, file) + try: + remove(filename) + except Exception, e: + self.logDebug("Error deleting \"%s\"" % path.basename(filename), str(e)) + err = True - if isfile(pyc_filename): + filename += "c" + if path.isfile(filename): try: if type == "hook": self.manager.deactivateHook(name) - remove(pyc_filename) + remove(filename) except Exception, e: - self.logError("Error deleting file %s" % pyc_filename, str(e)) - if rflag: + self.logDebug("Error deleting \"%s\"" % path.basename(filename), str(e)) + err = True + + if not err: id = (type, name) removed.append(id) -- cgit v1.2.3 From 98d4c07b6983c98fca26f99dd7a853ab36a1d696 Mon Sep 17 00:00:00 2001 From: stickell Date: Sun, 31 Aug 2014 17:55:36 +0200 Subject: [Checksum] Moved the checksum validation toggle to the plugin because the general configuration has been removed in 0.4.10 --- module/plugins/hooks/Checksum.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 0fe2ae88c..013172899 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -40,17 +40,18 @@ def computeChecksum(local_file, algorithm): class Checksum(Hook): __name__ = "Checksum" __type__ = "hook" - __version__ = "0.12" + __version__ = "0.13" __config__ = [("activated", "bool", "Activated", False), + ("check_checksum", "bool", "Check checksum? (If False only size will be verified)", True), ("check_action", "fail;retry;nothing", "What to do if check fails?", "retry"), ("max_tries", "int", "Number of retries", 2), ("retry_action", "fail;nothing", "What to do if all retries fail?", "fail"), ("wait_time", "int", "Time to wait before each retry (seconds)", 1)] __description__ = """Verify downloaded file size and checksum""" - __author_name__ = ("zoidberg", "Walter Purcaro") - __author_mail__ = ("zoidberg@mujmail.cz", "vuolter@gmail.com") + __author_name__ = ("zoidberg", "Walter Purcaro", "stickell") + __author_mail__ = ("zoidberg@mujmail.cz", "vuolter@gmail.com", "l.stickell@yahoo.it") methods = {'sfv': 'crc32', 'crc': 'crc32', 'hash': 'md5'} regexps = {'sfv': r'^(?P[^;].+)\s+(?P[0-9A-Fa-f]{8})$', @@ -60,8 +61,8 @@ class Checksum(Hook): def coreReady(self): - if not self.config['general']['checksum']: - self.logInfo("Checksum validation is disabled in general configuration") + if not self.getConfig("check_checksum"): + self.logInfo("Checksum validation is disabled in plugin configuration") def setup(self): self.algorithms = sorted( @@ -105,7 +106,7 @@ class Checksum(Hook): del data['size'] # validate checksum - if data and self.config['general']['checksum']: + if data and self.getConfig("check_checksum"): if "checksum" in data: data['md5'] = data['checksum'] -- cgit v1.2.3