diff options
Diffstat (limited to 'module/plugins/addons')
-rw-r--r-- | module/plugins/addons/DebridItaliaCom.py | 4 | ||||
-rw-r--r-- | module/plugins/addons/DeleteFinished.py | 86 | ||||
-rw-r--r-- | module/plugins/addons/DownloadScheduler.py | 72 | ||||
-rw-r--r-- | module/plugins/addons/MultiDebridCom.py | 42 | ||||
-rw-r--r-- | module/plugins/addons/RestartFailed.py | 124 |
5 files changed, 294 insertions, 34 deletions
diff --git a/module/plugins/addons/DebridItaliaCom.py b/module/plugins/addons/DebridItaliaCom.py index d570eebe3..80cdc45f6 100644 --- a/module/plugins/addons/DebridItaliaCom.py +++ b/module/plugins/addons/DebridItaliaCom.py @@ -20,7 +20,7 @@ from module.plugins.internal.MultiHoster import MultiHoster class DebridItaliaCom(MultiHoster): __name__ = "DebridItaliaCom" - __version__ = "0.03" + __version__ = "0.05" __type__ = "hook" __config__ = [("activated", "bool", "Activated", "False"), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), @@ -38,4 +38,4 @@ class DebridItaliaCom(MultiHoster): "bitshare.com", "share-links.biz", "putlocker.com", "uploaded.to", "speedload.org", "rapidgator.net", "likeupload.net", "cyberlocker.ch", "depositfiles.com", "extabit.com", "filefactory.com", "sharefiles.co", - "ryushare.com", "tusfiles.net", "nowvideo.co"] + "ryushare.com", "tusfiles.net", "nowvideo.co", "cloudzer.net", "letitbit.net"] diff --git a/module/plugins/addons/DeleteFinished.py b/module/plugins/addons/DeleteFinished.py new file mode 100644 index 000000000..e0df69eef --- /dev/null +++ b/module/plugins/addons/DeleteFinished.py @@ -0,0 +1,86 @@ + # -*- 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 <http://www.gnu.org/licenses/>. + + @author: Walter Purcaro +""" + +from module.plugins.Hook import Hook +from time import time + + +class DeleteFinished(Hook): + __name__ = "DeleteFinished" + __version__ = "0.5" + __description__ = "Automatically delete finished packages from queue" + __config__ = [ + ("activated", "bool", "Activated", "False"), + ("interval", "int", "Delete every (hours)", "72") + ] + __author_name__ = ("Walter Purcaro") + __author_mail__ = ("vuolter@gmail.com") + + def wakeup(self, pypack): + # self.logDebug("self.wakeup") + self.removeEvent("packageFinished", self.wakeup) + self.info["sleep"] = False + + def periodical(self): + # self.logDebug("self.periodical") + if not self.info["sleep"]: + self.core.api.deleteFinished() + self.logDebug("called self.core.api.deleteFinished") + self.info["sleep"] = True + self.addEvent("packageFinished", self.wakeup) + + def addEvent(self, event, handler): + if event in self.manager.events: + if handler not in self.manager.events[event]: + self.manager.events[event].append(handler) + # self.logDebug("self.addEvent: " + event + ": added handler") + else: + # self.logDebug("self.addEvent: " + event + ": NOT added handler") + return False + else: + self.manager.events[event] = [handler] + # self.logDebug("self.addEvent: " + event + ": added event and handler") + return True + + def removeEvent(self, event, handler): + if event in self.manager.events and handler in self.manager.events[event]: + self.manager.events[event].remove(handler) + # self.logDebug("self.removeEvent: " + event + ": removed handler") + return True + else: + # self.logDebug("self.removeEvent: " + event + ": NOT removed handler") + return False + + def configEvents(self, plugin=None, name=None, value=None): + # self.logDebug("self.configEvents") + interval = self.getConfig("interval") * 3600 + if interval != self.interval: + self.interval = interval + + def unload(self): + # self.logDebug("self.unload") + self.removeEvent("pluginConfigChanged", self.configEvents) + self.removeEvent("packageFinished", self.wakeup) + + def coreReady(self): + # self.logDebug("self.coreReady") + self.info = {"sleep": True} + self.addEvent("pluginConfigChanged", self.configEvents) + self.configEvents() + self.addEvent("packageFinished", self.wakeup) diff --git a/module/plugins/addons/DownloadScheduler.py b/module/plugins/addons/DownloadScheduler.py index 7cadede38..4049d71c5 100644 --- a/module/plugins/addons/DownloadScheduler.py +++ b/module/plugins/addons/DownloadScheduler.py @@ -18,61 +18,69 @@ import re from time import localtime + from module.plugins.Hook import Hook + class DownloadScheduler(Hook): __name__ = "DownloadScheduler" - __version__ = "0.20" + __version__ = "0.21" __description__ = """Download Scheduler""" - __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")] - __author_name__ = ("zoidberg") - __author_mail__ = ("zoidberg@mujmail.cz") - + __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")] + __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 - + self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded + def coreReady(self): self.updateSchedule() - - def updateSchedule(self, schedule = None): - if schedule is None: - schedule = self.getConfig("timetable") - - schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", schedule.lower().replace("full", "-1").replace("none", "0")) + + def updateSchedule(self, schedule=None): + if schedule is None: + schedule = self.getConfig("timetable") + + schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", + schedule.lower().replace("full", "-1").replace("none", "0")) if not schedule: self.logError("Invalid schedule") return - + t0 = localtime() now = (t0.tm_hour, t0.tm_min, t0.tm_sec, "X") schedule = sorted([(int(x[0]), int(x[1]), 0, int(x[2])) for x in schedule] + [now]) - - self.logDebug("Schedule", schedule) - + + self.logDebug("Schedule", schedule) + for i, v in enumerate(schedule): if v[3] == "X": - last, next = schedule[i-1], schedule[(i+1) % len(schedule)] + last, next = schedule[i - 1], schedule[(i + 1) % len(schedule)] self.logDebug("Now/Last/Next", now, last, next) - - self.setDownloadSpeed(last[3]) - - next_time = (((24 + next[0] - now[0])* 60 + next[1] - now[1]) * 60 + next[2] - now[2]) % 86400 + + self.setDownloadSpeed(last[3]) + + next_time = (((24 + next[0] - now[0]) * 60 + next[1] - now[1]) * 60 + next[2] - now[2]) % 86400 self.core.scheduler.removeJob(self.cb) - self.cb = self.core.scheduler.addJob(next_time, self.updateSchedule, threaded=False) - - def setDownloadSpeed(self, speed): + self.cb = self.core.scheduler.addJob(next_time, self.updateSchedule, threaded=False) + + def setDownloadSpeed(self, speed): if speed == 0: - self.logInfo("Stopping download server. (Running downloads will not be aborted.)") + abort = self.getConfig("abort") + self.logInfo("Stopping download server. (Running downloads will %sbe aborted.)" % ('' if abort else 'not ')) self.core.api.pauseServer() + if abort: + self.core.api.stopAllDownloads() else: self.core.api.unpauseServer() - + if speed > 0: self.logInfo("Setting download speed to %d kB/s" % speed) - self.core.api.setConfigValue("download","limit_speed",1) - self.core.api.setConfigValue("download","max_speed",speed) + self.core.api.setConfigValue("download", "limit_speed", 1) + self.core.api.setConfigValue("download", "max_speed", speed) else: self.logInfo("Setting download speed to FULL") - self.core.api.setConfigValue("download","limit_speed",0) - self.core.api.setConfigValue("download","max_speed",-1)
\ No newline at end of file + self.core.api.setConfigValue("download", "limit_speed", 0) + self.core.api.setConfigValue("download", "max_speed", -1) diff --git a/module/plugins/addons/MultiDebridCom.py b/module/plugins/addons/MultiDebridCom.py new file mode 100644 index 000000000..c95138648 --- /dev/null +++ b/module/plugins/addons/MultiDebridCom.py @@ -0,0 +1,42 @@ +# -*- 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 <http://www.gnu.org/licenses/>. # +############################################################################ + +from module.plugins.internal.MultiHoster import MultiHoster +from module.network.RequestFactory import getURL +from module.common.json_layer import json_loads + + +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)", ""), + ("unloadFailing", "bool", "Revert to standard download if download fails", "False"), + ("interval", "int", "Reload interval in hours (0 to disable)", "24")] + + __description__ = """Multi-debrid.com hook plugin""" + __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) + json_data = json_loads(json_data) + + return json_data['hosts'] diff --git a/module/plugins/addons/RestartFailed.py b/module/plugins/addons/RestartFailed.py new file mode 100644 index 000000000..7ee53deb9 --- /dev/null +++ b/module/plugins/addons/RestartFailed.py @@ -0,0 +1,124 @@ + # -*- 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 <http://www.gnu.org/licenses/>. + + @author: Walter Purcaro +""" + +from module.plugins.Hook import Hook +from time import time + + +class RestartFailed(Hook): + __name__ = "RestartFailed" + __version__ = "1.5" + __description__ = "Automatically restart failed/aborted downloads" + __config__ = [ + ("activated", "bool", "Activated", "True"), + ("dlFail", "bool", "Restart when download fail", "True"), + ("dlFail_n", "int", "Only when failed downloads are at least", "5"), + ("dlFail_i", "int", "Only when elapsed time since last restart is (min)", "10"), + ("dlPrcs", "bool", "Restart after all downloads are processed", "True"), + ("recnt", "bool", "Restart after reconnecting", "True"), + ("rsLoad", "bool", "Restart on plugin activation", "False") + ] + __author_name__ = ("Walter Purcaro") + __author_mail__ = ("vuolter@gmail.com") + + def restart(self, arg=None): + # self.logDebug("self.restart") + self.info["timerflag"] = False + self.info["dlfailed"] = 0 + self.core.api.restartFailed() + self.logDebug("self.restart: self.core.api.restartFailed") + self.info["lastrstime"] = time() + + def periodical(self): + # self.logDebug("self.periodical") + if self.info["timerflag"]: + self.restart() + + def checkInterval(self, arg=None): + # self.logDebug("self.checkInterval") + now = time() + lastrstime = self.info["lastrstime"] + interval = self.getConfig("dlFail_i") * 60 + if now < lastrstime + interval: + self.info["timerflag"] = True + else: + self.restart() + + def checkFailed(self, pyfile): + # self.logDebug("self.checkFailed") + self.info["dlfailed"] += 1 + curr = self.info["dlfailed"] + max = self.getConfig("dlFail_n") + if curr >= max: + self.checkInterval() + + def addEvent(self, event, handler): + if event in self.manager.events: + if handler not in self.manager.events[event]: + self.manager.events[event].append(handler) + # self.logDebug("self.addEvent: " + event + ": added handler") + else: + # self.logDebug("self.addEvent: " + event + ": NOT added handler") + return False + else: + self.manager.events[event] = [handler] + # self.logDebug("self.addEvent: " + event + ": added event and handler") + return True + + def removeEvent(self, event, handler): + if event in self.manager.events and handler in self.manager.events[event]: + self.manager.events[event].remove(handler) + # self.logDebug("self.removeEvent: " + event + ": removed handler") + return True + else: + # self.logDebug("self.removeEvent: " + event + ": NOT removed handler") + return False + + def configEvents(self, plugin=None, name=None, value=None): + # self.logDebug("self.configEvents") + self.interval = self.getConfig("dlFail_i") * 60 + dlFail = self.getConfig("dlFail") + dlPrcs = self.getConfig("dlPrcs") + recnt = self.getConfig("recnt") + if dlPrcs: + self.addEvent("allDownloadsProcessed", self.checkInterval) + else: + self.removeEvent("allDownloadsProcessed", self.checkInterval) + if not dlFail: + self.info["timerflag"] = False + if recnt: + self.addEvent("afterReconnecting", self.restart) + else: + self.removeEvent("afterReconnecting", self.restart) + + def unload(self): + # self.logDebug("self.unload") + self.removeEvent("pluginConfigChanged", self.configEvents) + self.removeEvent("downloadFailed", self.checkFailed) + self.removeEvent("allDownloadsProcessed", self.checkInterval) + self.removeEvent("afterReconnecting", self.restart) + + def coreReady(self): + # self.logDebug("self.coreReady") + self.info = {"dlfailed": 0, "lastrstime": 0, "timerflag": False} + if self.getConfig("rsLoad"): + self.restart() + self.addEvent("downloadFailed", self.checkFailed) + self.addEvent("pluginConfigChanged", self.configEvents) + self.configEvents() |