From c2e18511923ebda7a8a87ef9c35a9cb88c799e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Sun, 22 Feb 2015 17:53:32 +0100 Subject: [ExtractArchive] preventing duplicate files extraction --- module/plugins/hooks/ExtractArchive.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index a1e85ba57..8b84966fd 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.30" + __version__ = "1.31" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -269,7 +269,8 @@ class ExtractArchive(Hook): matched = False success = True - files_ids = [(save_join(dl, pypack.folder, pylink['name']), pylink['id'], out) for pylink in pypack.getChildren().itervalues()] + files_ids = dict((pylink['name'],((save_join(dl, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ + in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() # remove duplicates # check as long there are unseen files while files_ids: -- cgit v1.2.3 From 64f4b1f856f3653136f8f0ac7150491598966f67 Mon Sep 17 00:00:00 2001 From: flubshi Date: Mon, 23 Feb 2015 12:26:22 +0100 Subject: [Hook] Free-way.me: Use login data while getting host list --- module/plugins/hooks/FreeWayMe.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index 6fec037d8..f819f730d 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class FreeWayMe(MultiHook): __name__ = "FreeWayMe" __type__ = "hook" - __version__ = "0.14" + __version__ = "0.15" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -22,6 +22,13 @@ class FreeWayMe(MultiHook): def getHosters(self): - hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={'id': 3}).replace("\"", "").strip() - self.logDebug("Hosters", hostis) + # Get account data + if not self.account or not self.account.canUse(): + hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3}).replace("\"", "").strip() + else: + self.logDebug("AccountInfo available - Get HosterList with User Pass") + (user, data) = self.account.selectAccount() + hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3, "user": user, "pass": data['password']}).replace("\"", "").strip() + + self.logDebug("hosters: %s" % hostis) return [x.strip() for x in hostis.split(",") if x.strip()] -- cgit v1.2.3 From 0e7a0295c60e93a7e095207176e465e82c03dc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Tue, 24 Feb 2015 10:28:47 +0100 Subject: [ExtractArchive] fixes https://github.com/pyload/pyload/issues/1206 --- module/plugins/hooks/ExtractArchive.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8b84966fd..dc0ee3f41 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.31" + __version__ = "1.32" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -254,6 +254,7 @@ class ExtractArchive(Hook): pypack = self.core.files.getPackage(pid) if not pypack: + self.queue.remove(pid) continue self.logInfo(_("Check package: %s") % pypack.name) -- cgit v1.2.3 From ed9bbe7332d8f6e2bf33b09ae5382a4925d2eac3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 24 Feb 2015 23:57:38 +0100 Subject: [ExternalScripts] Code cosmetics --- module/plugins/hooks/ExternalScripts.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 8bd803308..3b9c9ca05 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -3,8 +3,6 @@ import os import subprocess -from itertools import chain - from module.plugins.Hook import Hook from module.utils import save_join @@ -142,10 +140,10 @@ class ExternalScripts(Hook): def allDownloadsFinished(self): - for script in chain(self.scripts['all_downloads_finished'], self.scripts['all_dls_finished']): + for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']): self.callScript(script) def allDownloadsProcessed(self): - for script in chain(self.scripts['all_downloads_processed'], self.scripts['all_dls_processed']): + for script in self.scripts['all_downloads_processed'] + self.scripts['all_dls_processed']: self.callScript(script) -- cgit v1.2.3 From 808d8036fc8cc13c4b26240818bd86ac82567e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Wed, 25 Feb 2015 20:25:20 +0100 Subject: [ExternalScripts] Code cosmetics - cosmetics --- module/plugins/hooks/ExternalScripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 3b9c9ca05..f49220c2a 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -140,7 +140,7 @@ class ExternalScripts(Hook): def allDownloadsFinished(self): - for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']): + for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']: self.callScript(script) -- cgit v1.2.3 From 93eb54614d512396a5505cb9bdea4e201920b434 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 1 Mar 2015 00:33:21 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/ExtractArchive.py | 12 ++++++------ module/plugins/hooks/FreeWayMe.py | 2 +- module/plugins/hooks/JustPremium.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 6691bb1fe..5b21aec96 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -53,7 +53,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - self.logInfo(_("Proxy listening on %s:%s") % (ip, cnlport)) + self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) self.manager.startThread(self._server, ip, webport, cnlport) lock = Lock() lock.acquire() diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index dc0ee3f41..c9e43eaaf 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -327,10 +327,10 @@ class ExtractArchive(Hook): if recursive and os.path.isfile(file): new_files_ids.append((filename, fid, os.path.dirname(filename))) # append as new target - + pyfile = self.core.files.getFile(fid) self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, new_files) - + files_ids = new_files_ids # also check extracted files if matched: @@ -381,7 +381,7 @@ class ExtractArchive(Hook): pyfile.setProgress(100) else: archive.check(pw) - + self.addPassword(pw) break @@ -389,7 +389,7 @@ class ExtractArchive(Hook): if not encrypted: self.logInfo(name, _("Password protected")) encrypted = True - + except CRCError, e: self.logDebug(name, e) self.logInfo(name, _("CRC Error")) @@ -407,9 +407,9 @@ class ExtractArchive(Hook): self.addPassword(pw) break - + raise CRCError("Archive damaged") - + except ArchiveError, e: raise ArchiveError(e) diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index f819f730d..4e79783bb 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -29,6 +29,6 @@ class FreeWayMe(MultiHook): self.logDebug("AccountInfo available - Get HosterList with User Pass") (user, data) = self.account.selectAccount() hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3, "user": user, "pass": data['password']}).replace("\"", "").strip() - + self.logDebug("hosters: %s" % hostis) return [x.strip() for x in hostis.split(",") if x.strip()] diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index b70d8dd2c..30a72c70f 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -12,7 +12,7 @@ class JustPremium(Hook): __config__ = [("excluded", "str", "Exclude hosters (comma separated)", "")] - __description__ = """Remove all not premium links from urls added""" + __description__ = """Remove not-premium links from added urls""" __license__ = "GPLv3" __authors__ = [("mazleu", "mazleica@gmail.com"), ("Walter Purcaro", "vuolter@gmail.com"), -- cgit v1.2.3 From 5eb1729ab45fcdb4862f2b4e54bdb79d7f59a6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Sun, 1 Mar 2015 14:14:32 +0100 Subject: [JustPremium] Include hoster to remove --- module/plugins/hooks/JustPremium.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 30a72c70f..daefbc30f 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -8,9 +8,10 @@ from module.plugins.Hook import Hook class JustPremium(Hook): __name__ = "JustPremium" __type__ = "hook" - __version__ = "0.21" + __version__ = "0.22" - __config__ = [("excluded", "str", "Exclude hosters (comma separated)", "")] + __config__ = [("excluded", "str", "Exclude hosters (comma separated)", ""), + ("included", "str", "Include hosters (comma separated)", "")] __description__ = """Remove not-premium links from added urls""" __license__ = "GPLv3" @@ -32,14 +33,18 @@ class JustPremium(Hook): if 'new_name' in hosterdict[hoster] \ and hosterdict[hoster]['new_name'] in premiumplugins) - #: Found at least one hoster with account or multihoster - if not any(True for pluginname in linkdict if pluginname in premiumplugins | multihosters): - return - excluded = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), self.getConfig('excluded').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) + included = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), + self.getConfig('included').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) + + hosterlist = (premiumplugins | multihosters).union(excluded).difference(included) + + #: Found at least one hoster with account or multihoster + if not any( True for pluginname in linkdict if pluginname in hosterlist ): + return - for pluginname in set(linkdict.keys()) - (premiumplugins | multihosters).union(excluded): + for pluginname in set(linkdict.keys()) - hosterlist: self.logInfo(_("Remove links of plugin: %s") % pluginname) for link in linkdict[pluginname]: self.logDebug("Remove link: %s" % link) -- cgit v1.2.3 From 6c6ff624f7445ad8fb92c5947ad23248d62058c6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 1 Mar 2015 21:56:38 +0100 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1089 --- module/plugins/hooks/UpdateManager.py | 76 +++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 31 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index b6a8bac7c..a0b044edb 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -2,21 +2,33 @@ from __future__ import with_statement +import os import re import sys from operator import itemgetter -from os import path, remove, stat from module.network.RequestFactory import getURL from module.plugins.Hook import Expose, Hook, threaded from module.utils import save_join +# Case-sensitive os.path.exists +def exists(path): + if os.path.exists(path): + if os.name == 'nt': + dir, name = os.path.split(path) + return name in os.listdir(dir) + else: + return True + else: + return False + + class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.43" + __version__ = "0.44" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -95,10 +107,10 @@ class UpdateManager(Hook): id = (type, name) if type in self.core.pluginManager.plugins: f = m.__file__.replace(".pyc", ".py") - if not path.isfile(f): + if not os.path.isfile(f): continue - mtime = stat(f).st_mtime + mtime = os.stat(f).st_mtime if id not in self.mtimes: self.mtimes[id] = mtime @@ -114,9 +126,10 @@ class UpdateManager(Hook): self.updateThread() - def server_request(self): + def server_response(self): try: return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() + except Exception: self.logWarning(_("Unable to contact server to get updates")) @@ -142,7 +155,7 @@ class UpdateManager(Hook): @Expose def update(self, onlyplugin=False): """ check for updates """ - data = self.server_request() + data = self.server_response() if not data: exitcode = 0 @@ -202,7 +215,7 @@ class UpdateManager(Hook): break for t, n in self.removePlugins(sorted(blacklisted)): - self.logInfo(_("Removed blacklisted plugin [%(type)s] %(name)s") % { + self.logInfo(_("Removed blacklisted plugin: [%(type)s] %(name)s") % { 'type': t, 'name': n, }) @@ -217,7 +230,7 @@ class UpdateManager(Hook): else: name = filename.replace(".py", "") - #@TODO: obsolete after 0.4.10 + #@TODO: Remove in 0.4.10 if prefix.endswith("s"): type = prefix[:-1] else: @@ -276,35 +289,36 @@ class UpdateManager(Hook): if not type_plugins: return - self.logDebug("Requested deletion of plugins: %s" % type_plugins) + removed = set() - removed = [] + self.logDebug("Requested deletion of plugins: %s" % type_plugins) for type, name in type_plugins: - err = False - file = name + ".py" + rootplugins = os.path.join(pypath, "module", "plugins") - for root in ("userplugins", path.join(pypath, "module", "plugins")): + for dir in ("userplugins", rootplugins): + py_filename = save_join(dir, type, name + ".py") + pyc_filename = py_filename + "c" - filename = save_join(root, type, file) - try: - remove(filename) - except Exception, e: - self.logDebug("Error removing: %s" % path.basename(filename), str(e)) - err = True - - filename += "c" - if path.isfile(filename): + if type == "hook": try: - if type == "hook": - self.manager.deactivateHook(name) - remove(filename) + self.manager.deactivateHook(name) + except Exception, e: - self.logDebug("Error removing: %s" % path.basename(filename), str(e)) - err = True + self.logDebug(e) + + for filename in (py_filename, pyc_filename): + if not exists(filename): + continue + + try: + os.remove(filename) + + except IOError, e: + self.logError(_("Error removing: %s") % filename, e) - if not err: - id = (type, name) - removed.append(id) + else: + id = (type, name) + removed.add(id) - return removed #: return a list of the plugins successfully removed + return list(removed) #: return a list of the plugins successfully removed -- cgit v1.2.3 From 3a9c167ceca27d57dbef927626fe853a3d0e30b2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 1 Mar 2015 22:41:08 +0100 Subject: [Extractor] Use self.target --- module/plugins/hooks/ExtractArchive.py | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c9e43eaaf..6a25602e8 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -33,6 +33,7 @@ if sys.version_info < (2, 7) and os.name != "nt": if self.returncode is None: try: pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0) + except OSError, e: if e.errno != errno.ECHILD: raise @@ -93,10 +94,13 @@ class ArchiveQueue(object): queue = self.get() try: queue.remove(item) + except ValueError: pass + if queue == []: return self.delete() + return self.set(queue) @@ -106,22 +110,22 @@ class ExtractArchive(Hook): __type__ = "hook" __version__ = "1.32" - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (rar required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile" , "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive when successfully extracted", False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Wait for all downloads to be finished" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (rar required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "bool" , "Delete archive when successfully extracted", False ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder", "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Wait for all downloads to be finished" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -175,6 +179,7 @@ class ExtractArchive(Hook): else: self.logInfo(_("No Extract plugins activated")) + @threaded def extractQueued(self,thread): packages = self.queue.get() -- cgit v1.2.3 From 5ea0fe898b435a5654e0a14172025779c82182d6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 2 Mar 2015 00:39:51 +0100 Subject: [ClickAndLoad] Revert and improve --- module/plugins/hooks/ClickAndLoad.py | 50 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 5b21aec96..1a7dec6ac 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -16,6 +16,7 @@ def forward(source, destination): destination.sendall(bufdata) bufdata = source.recv(bufsize) finally: + source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) @@ -23,13 +24,13 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.37" + __version__ = "0.38" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), ("extern" , "bool", "Listen on the public network interface", True)] - __description__ = """Click'N'Load hook plugin""" + __description__ = """Click'n'Load hook plugin""" __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.de"), ("Walter Purcaro", "vuolter@gmail.com")] @@ -45,7 +46,7 @@ class ClickAndLoad(Hook): return ip = "" if self.getConfig("extern") else "127.0.0.1" - webport = int(self.config['webinterface']['port']) + webport = self.config['webinterface']['port'] cnlport = self.getConfig('port') self.proxy(ip, webport, cnlport) @@ -54,39 +55,36 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) - self.manager.startThread(self._server, ip, webport, cnlport) + + self._server(ip, webport, cnlport) + lock = Lock() lock.acquire() lock.acquire() - def _server(self, ip, webport, cnlport, thread): + @threaded + def _server(self, ip, webport, cnlport): try: - try: - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket.bind((ip, cnlport)) + dock_socket.listen(1) - server_socket.bind((ip, cnlport)) - server_socket.listen(5) + while True: + client_socket, client_addr = dock_socket.accept() + self.logDebug("Connection from: %s" % client_addr) - while True: - client_socket = server_socket.accept()[0] - dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - dock_socket.connect(("127.0.0.1", webport)) - - self.manager.startThread(forward, dock_socket, client_socket) - self.manager.startThread(forward, client_socket, dock_socket) + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server_socket.connect(("127.0.0.1", webport)) - except socket.timeout: - self.logDebug("Connection timed out, retrying...") - return self._server(ip, webport, cnlport, thread) + self.manager.startThread(forward, client_socket, server_socket) + self.manager.startThread(forward, server_socket, client_socket) - finally: - server_socket.close() - client_socket.close() - dock_socket.close() + except socket.timeout: + self.logDebug("Connection timed out, retrying...") + return self._server(ip, webport, cnlport) except socket.error, e: self.logError(e) - time.sleep(120) - self._server(ip, webport, cnlport, thread) + time.sleep(240) + return self._server(ip, webport, cnlport) -- cgit v1.2.3 From 8d85fb7c11dfa83052d09402dbae21dde44392aa Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 4 Mar 2015 03:12:58 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1220 --- module/plugins/hooks/ClickAndLoad.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 1a7dec6ac..f3396be77 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -16,15 +16,15 @@ def forward(source, destination): destination.sendall(bufdata) bufdata = source.recv(bufsize) finally: - source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) + destination.close() #@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.38" + __version__ = "0.39" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -68,11 +68,11 @@ class ClickAndLoad(Hook): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) dock_socket.bind((ip, cnlport)) - dock_socket.listen(1) + dock_socket.listen(5) while True: client_socket, client_addr = dock_socket.accept() - self.logDebug("Connection from: %s" % client_addr) + self.logDebug("Connection from %s:%s" % client_addr) server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.connect(("127.0.0.1", webport)) -- cgit v1.2.3 From 9854d2f81577dc3c5c7c97cefd61404f739f4a24 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 5 Mar 2015 23:15:19 +0100 Subject: [ClickAndLoad] Fixup --- module/plugins/hooks/ClickAndLoad.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index f3396be77..938269795 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -17,14 +17,14 @@ def forward(source, destination): bufdata = source.recv(bufsize) finally: destination.shutdown(socket.SHUT_WR) - destination.close() + # destination.close() #@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.39" + __version__ = "0.40" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), -- cgit v1.2.3 From 0685e1f1d55e8a1a3083ca147ad4087430fc2620 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 6 Mar 2015 03:32:08 +0100 Subject: [SkipRev] Fix https://github.com/pyload/pyload/issues/1217 --- module/plugins/hooks/SkipRev.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 0bbdec3b2..3ebfa378e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,9 +18,10 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.25" + __version__ = "0.26" - __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] + __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), + ("tokeep", "int" , "Custom number of files to keep" , 0 )] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" @@ -32,8 +33,8 @@ class SkipRev(Hook): pass - def _pyname(self, pyfile): - if hasattr(pyfile.pluginmodule, "getInfo"): + def _name(self, pyfile): + if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") @@ -54,16 +55,19 @@ class SkipRev(Hook): def downloadPreparing(self, pyfile): - if pyfile.statusname is "unskipped" or not self._pyname(pyfile).endswith(".rev"): + name = self._name(pyfile) + + if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not '.part' in name: return - tokeep = self.getConfig("tokeep") + tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') if tokeep: status_list = (1, 4, 8, 9, 14) if tokeep < 0 else (1, 3, 4, 8, 9, 14) + pyname = re.compile(r'%s\.part\d+\.rev$' % name.rsplit('.', 2)[0].replace('.', '\.')) queued = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ - if link.name.endswith(".rev") and link.status not in status_list].count(True) + if link.status not in status_list and pyname.match(link.name)].count(True) if not queued or queued < tokeep: #: keep one rev at least in auto mode return @@ -76,16 +80,18 @@ class SkipRev(Hook): def downloadFailed(self, pyfile): #: Check if pyfile is still "failed", # maybe might has been restarted in meantime - if pyfile.status != 8: + if pyfile.status != 8 or pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): return - tokeep = self.getConfig("tokeep") + tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') if not tokeep: return + pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.')) + for link in self.core.api.getPackageData(pyfile.package().id).links: - if link.status is 4 and link.name.endswith(".rev"): + if link.status is 4 and pyname.match(link.name): pylink = self._pyfile(link) if tokeep > -1 or pyfile.name.endswith(".rev"): -- cgit v1.2.3 From cb52389931917fee9a6116b45922f502480350d6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 6 Mar 2015 03:45:46 +0100 Subject: [SkipRev] Fix setup loop on download preparing --- module/plugins/hooks/SkipRev.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 3ebfa378e..a543ef71c 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,7 +18,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.26" + __version__ = "0.27" __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), ("tokeep", "int" , "Custom number of files to keep" , 0 )] @@ -57,7 +57,7 @@ class SkipRev(Hook): def downloadPreparing(self, pyfile): name = self._name(pyfile) - if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not '.part' in name: + if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not ".part" in name: return tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') @@ -73,8 +73,10 @@ class SkipRev(Hook): return pyfile.setCustomStatus("SkipRev", "skipped") - pyfile.plugin._setup = pyfile.plugin.setup - pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin + + if not hasattr(pyfile.plugin, "_setup"): + pyfile.plugin._setup = pyfile.plugin.setup + pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin def downloadFailed(self, pyfile): -- cgit v1.2.3 From 5f4b7afb0bf8f770032ee21ce67c76194d8d6cb0 Mon Sep 17 00:00:00 2001 From: jellysheep Date: Fri, 6 Mar 2015 14:24:22 +0100 Subject: [ExternalScripts] Encode unicode characters If a file with unicode characters in the filename is downloaded ExternalScripts.py fails with e.g. this error: ExternalScripts: Error in download_finished.sh: 'ascii' codec can't decode byte 0xc3 in position 29: ordinal not in range(128) This commit makes the plugin encode unicode characters to UTF-8. --- module/plugins/hooks/ExternalScripts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index f49220c2a..76a9d9c52 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -74,7 +74,8 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [script] + [str(x) if not isinstance(x, basestring) else x for x in args] + cmd = [script] + [x.encode("UTF-8") if isinstance(x, unicode) else + str(x) if not isinstance(x, basestring) else x for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) -- cgit v1.2.3 From 6aa9ab4f05a9fb5f5fc9cbe1758591cd239ba089 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 6 Mar 2015 18:30:56 +0100 Subject: [SkipRev] Fix https://github.com/pyload/pyload/issues/1217 (2) --- module/plugins/hooks/SkipRev.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index a543ef71c..034d2b803 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import re + from types import MethodType from urllib import unquote from urlparse import urlparse @@ -18,7 +20,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.27" + __version__ = "0.28" __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), ("tokeep", "int" , "Custom number of files to keep" , 0 )] @@ -35,7 +37,7 @@ class SkipRev(Hook): def _name(self, pyfile): if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 - return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]).next()[0] + return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") return urlparse(unquote(pyfile.url)).path.split('/')[-1] -- cgit v1.2.3 From acc20db31c63ed03ce3e0c530a0b0bc24444e980 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 6 Mar 2015 22:31:52 +0100 Subject: [ExternalScripts] Version up --- module/plugins/hooks/ExternalScripts.py | 5 ++--- module/plugins/hooks/SkipRev.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 76a9d9c52..a09d5e92e 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.29" + __version__ = "0.30" __config__ = [("activated", "bool", "Activated" , True ), ("wait" , "bool", "Wait script ending", False)] @@ -74,8 +74,7 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [script] + [x.encode("UTF-8") if isinstance(x, unicode) else - str(x) if not isinstance(x, basestring) else x for x in args] + cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 034d2b803..a4d46316e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -22,8 +22,8 @@ class SkipRev(Hook): __type__ = "hook" __version__ = "0.28" - __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), - ("tokeep", "int" , "Custom number of files to keep" , 0 )] + __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), + ("revtokeep", "int" , "Custom number of files to keep" , 0 )] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" @@ -62,16 +62,16 @@ class SkipRev(Hook): if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not ".part" in name: return - tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') + revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') - if tokeep: - status_list = (1, 4, 8, 9, 14) if tokeep < 0 else (1, 3, 4, 8, 9, 14) + if revtokeep: + status_list = (1, 4, 8, 9, 14) if revtokeep < 0 else (1, 3, 4, 8, 9, 14) pyname = re.compile(r'%s\.part\d+\.rev$' % name.rsplit('.', 2)[0].replace('.', '\.')) queued = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ if link.status not in status_list and pyname.match(link.name)].count(True) - if not queued or queued < tokeep: #: keep one rev at least in auto mode + if not queued or queued < revtokeep: #: keep one rev at least in auto mode return pyfile.setCustomStatus("SkipRev", "skipped") @@ -87,9 +87,9 @@ class SkipRev(Hook): if pyfile.status != 8 or pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): return - tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') + revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') - if not tokeep: + if not revtokeep: return pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.')) @@ -98,7 +98,7 @@ class SkipRev(Hook): if link.status is 4 and pyname.match(link.name): pylink = self._pyfile(link) - if tokeep > -1 or pyfile.name.endswith(".rev"): + if revtokeep > -1 or pyfile.name.endswith(".rev"): pylink.setStatus("queued") else: pylink.setCustomStatus("unskipped", "queued") -- cgit v1.2.3 From 9b8bd41059d87e120d2d64bc0e01e0a521ec1082 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 7 Mar 2015 03:32:50 +0100 Subject: New addon: AntiVirus --- module/plugins/hooks/AntiVirus.py | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 module/plugins/hooks/AntiVirus.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py new file mode 100644 index 000000000..4bb2396d9 --- /dev/null +++ b/module/plugins/hooks/AntiVirus.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +import os +import subprocess + +from module.plugins.Hook import Hook, Expose, threaded +from module.utils import fs_encode, save_join + + +class AntiVirus(Hook): + __name__ = "AntiVirus" + __type__ = "hook" + __version__ = "0.01" + + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), + ("quarpath" , "folder" , "Quarantine folder" , "" ), + ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), + ("cmdpath" , "file" , "Antivirus executable" , "" ), + ("cmdargs" , "str" , "Scan options" , "" )] + + __description__ = """Scan downloaded files with antivirus program""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + + @Expose + @threaded + def scan(self, pyfile, thread): + name = os.path.basename(pyfile.plugin.lastDownload) + filename = fs_encode(pyfile.plugin.lastDownload) + cmdpath = fs_encode(self.getConfig('cmdpath')) + cmdargs = fs_encode(self.getConfig('cmdargs').strip()) + + if not os.path.isfile(filename) or not os.path.isfile(cmdpath): + return + + pyfile.setCustomStatus(_("virus scanning")) + thread.addActive(pyfile) + + try: + p = subprocess.Popen([cmdpath, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + out, err = map(str.strip, p.communicate()) + + if out: + self.logInfo(name, out) + + if err: + self.logWarning(name, err) + return + + if p.returncode: + action = self.getConfig('action') + try: + if action == "Delete": + os.remove(filename) + + elif action == "Quarantine": + new_filename = save_join(self.getConfig('quarpath'), name) + os.rename(filename, new_filename) + + except IOError, e: + self.logError(name, action + " action failed!", e) + + elif not out: + self.logDebug(name, "No virus found") + + finally: + thread.finishFile(pyfile) + + + def downloadFinished(self, pyfile): + return self.scan(pyfile) + + + def downloadFailed(self, pyfile): + #: Check if pyfile is still "failed", + # maybe might has been restarted in meantime + if pyfile.status == 8 and self.getConfig('scanfailed'): + return self.scan(pyfile) -- cgit v1.2.3 From c4f3a79f8ce19eab13ea7e53ff7a58fad43c6698 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 7 Mar 2015 03:39:08 +0100 Subject: [AntiVirus] Fix quarantine file moving --- module/plugins/hooks/AntiVirus.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 4bb2396d9..c5d6b8321 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os +import shutil import subprocess from module.plugins.Hook import Hook, Expose, threaded @@ -10,7 +11,7 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.01" + __version__ = "0.02" __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), ("quarpath" , "folder" , "Quarantine folder" , "" ), @@ -62,9 +63,9 @@ class AntiVirus(Hook): elif action == "Quarantine": new_filename = save_join(self.getConfig('quarpath'), name) - os.rename(filename, new_filename) + shutil.move(filename, new_filename) - except IOError, e: + except (IOError, shutil.Error), e: self.logError(name, action + " action failed!", e) elif not out: -- cgit v1.2.3 From 3551cd44c7fad9cf5159d5920b6e8ec7aa3d1b9b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 7 Mar 2015 18:33:23 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/AntiVirus.py | 45 ++++++++++++++++++++++----------------- module/plugins/hooks/SkipRev.py | 4 ++-- 2 files changed, 28 insertions(+), 21 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index c5d6b8321..5dbc640ee 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,13 +11,14 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), - ("quarpath" , "folder" , "Quarantine folder" , "" ), + ("quardir" , "folder" , "Quarantine folder" , "" ), ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), - ("cmdpath" , "file" , "Antivirus executable" , "" ), - ("cmdargs" , "str" , "Scan options" , "" )] + ("cmdfile" , "file" , "Antivirus executable" , "" ), + ("cmdargs" , "str" , "Scan options" , "" ), + ("ignore-err", "bool" , "Ignore scan errors" , False )] __description__ = """Scan downloaded files with antivirus program""" __license__ = "GPLv3" @@ -32,46 +33,52 @@ class AntiVirus(Hook): @Expose @threaded def scan(self, pyfile, thread): - name = os.path.basename(pyfile.plugin.lastDownload) - filename = fs_encode(pyfile.plugin.lastDownload) - cmdpath = fs_encode(self.getConfig('cmdpath')) + file = fs_encode(pyfile.plugin.lastDownload) + filename = os.path.basename(pyfile.plugin.lastDownload) + cmdfile = fs_encode(self.getConfig('cmdfile')) cmdargs = fs_encode(self.getConfig('cmdargs').strip()) - if not os.path.isfile(filename) or not os.path.isfile(cmdpath): + if not os.path.isfile(file) or not os.path.isfile(cmdfile): return - pyfile.setCustomStatus(_("virus scanning")) thread.addActive(pyfile) + pyfile.setCustomStatus(_("virus scanning")) try: - p = subprocess.Popen([cmdpath, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen([cmdfile, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = map(str.strip, p.communicate()) if out: - self.logInfo(name, out) + self.logInfo(filename, out) if err: - self.logWarning(name, err) - return + self.logWarning(filename, err) + if not self.getConfig('ignore-err') + self.logDebug("Delete/Quarantine action aborted") + return if p.returncode: + pyfile.error = _("infected file") action = self.getConfig('action') try: if action == "Delete": - os.remove(filename) + os.remove(file) elif action == "Quarantine": - new_filename = save_join(self.getConfig('quarpath'), name) - shutil.move(filename, new_filename) + pyfile.setCustomStatus(_("file moving")) + pyfile.setProgress(0) + new_filename = save_join(self.getConfig('quardir'), filename) + shutil.move(file, new_filename) except (IOError, shutil.Error), e: - self.logError(name, action + " action failed!", e) + self.logError(filename, action + " action failed!", e) - elif not out: - self.logDebug(name, "No virus found") + elif not out and not err: + self.logDebug(filename, "No infected file found") finally: + pyfile.setProgress(100) thread.finishFile(pyfile) diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index a4d46316e..521c2c39e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -22,8 +22,8 @@ class SkipRev(Hook): __type__ = "hook" __version__ = "0.28" - __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), - ("revtokeep", "int" , "Custom number of files to keep" , 0 )] + __config__ = [("mode" , "Auto;Manual", "Choose rev files to skip for package", "Auto"), + ("revtokeep", "int" , "Number of rev files to keep" , 0 )] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" -- cgit v1.2.3 From 696ae23db1192f919961685f4026bb917b15868d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 7 Mar 2015 21:06:53 +0100 Subject: [AntiVirus] Missed something big! :P --- module/plugins/hooks/AntiVirus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 5dbc640ee..695852683 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,7 +11,7 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), ("quardir" , "folder" , "Quarantine folder" , "" ), @@ -45,7 +45,7 @@ class AntiVirus(Hook): pyfile.setCustomStatus(_("virus scanning")) try: - p = subprocess.Popen([cmdfile, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen([cmdfile, cmdargs, file], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = map(str.strip, p.communicate()) -- cgit v1.2.3 From af353df35ef05b699f464ad2dca1b7b2bfe732e4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 01:14:57 +0100 Subject: [ExternalScripts] Improve --- module/plugins/hooks/ExternalScripts.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index a09d5e92e..76444d4b3 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -4,16 +4,16 @@ import os import subprocess from module.plugins.Hook import Hook -from module.utils import save_join +from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.30" + __version__ = "0.31" __config__ = [("activated", "bool", "Activated" , True ), - ("wait" , "bool", "Wait script ending", False)] + ("waitend" , "bool", "Wait script ending", False)] __description__ = """Run external scripts""" __license__ = "GPLv3" @@ -50,7 +50,7 @@ class ExternalScripts(Hook): for script_type, names in self.scripts.iteritems(): if names: - self.logInfo(_("Installed scripts for"), script_type, ", ".join(map(os.path.basename, names))) + self.logInfo(_("Installed scripts for ") + script_type, ", ".join(map(os.path.basename, names))) def initPluginType(self, folder, path): @@ -58,28 +58,33 @@ class ExternalScripts(Hook): try: os.makedirs(path) - except Exception: - self.logDebug("Script folder %s not created" % folder) + except IOError, e: + self.logDebug(e) return - for f in os.listdir(path): - if f.startswith("#") or f.startswith(".") or f.startswith("_") or f.endswith("~") or f.endswith(".swp"): + for filename in os.listdir(path): + file = os.path.join(path, filename) + + if not os.path.isfile(file): + continue + + if filename[0] in ("#", "_") or filename.endswith("~") or filename.endswith(".swp"): continue - if not os.access(os.path.join(path, f), os.X_OK): - self.logWarning(_("Script not executable:") + " %s/%s" % (folder, f)) + if not os.access(file, os.X_OK): + self.logWarning(_("Script not executable:") + " %s/%s" % (folder, filename)) - self.scripts[folder].append(os.path.join(path, f)) + self.scripts[folder].append(file) def callScript(self, script, *args): try: - cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] + cmd = [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) - p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload - if self.getConfig('wait'): + p = subprocess.Popen([script, fs_encode(cmd)], bufsize=-1) #@NOTE: output goes to pyload + if self.getConfig('waitend'): p.communicate() except Exception, e: -- cgit v1.2.3 From db330ae85f9de5a9a19c7141c1a2d6877e02e7da Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 23:32:11 +0100 Subject: Update notify addon --- module/plugins/hooks/AndroidPhoneNotify.py | 53 +++++++++++++++++++----------- module/plugins/hooks/WindowsPhoneNotify.py | 52 ++++++++++++++++++----------- 2 files changed, 65 insertions(+), 40 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index a3b24a255..7a9e6d6f8 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -1,27 +1,28 @@ # -*- coding: utf-8 -*- -from time import time +import time from module.network.RequestFactory import getURL -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, Expose class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("apikey" , "str" , "API key" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify processed packages status" , True ), - ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), - ("force" , "bool", "Send notifications if client is connected", False)] + ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), + ("sendpermin" , "int" , "Max notifications per minute" , 12 ), + ("ignoreclient" , "bool", "Send notifications if client is connected", False)] - __description__ = """Send push notifications to your Android Phone using notifymyandroid.com""" + __description__ = """Send push notifications to your Android Phone (using notifymyandroid.com)""" __license__ = "GPLv3" - __authors__ = [("Steven Kosyra", "steven.kosyra@gmail.com"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Steven Kosyra" , "steven.kosyra@gmail.com"), + ("Walter Purcaro", "vuolter@gmail.com" )] event_list = ["allDownloadsProcessed"] @@ -33,16 +34,14 @@ class AndroidPhoneNotify(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.last_notify = 0 + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 + self.notifications = 0 def newCaptchaTask(self, task): if not self.getConfig("notifycaptcha"): - return False - - if time() - self.last_notify < self.getConf("timeout"): - return False + return self.notify(_("Captcha"), _("New request waiting user input")) @@ -54,7 +53,7 @@ class AndroidPhoneNotify(Hook): def allDownloadsProcessed(self): if not self.getConfig("notifyprocessed"): - return False + return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): self.notify(_("Package failed"), _("One or more packages was not completed successfully")) @@ -62,14 +61,27 @@ class AndroidPhoneNotify(Hook): self.notify(_("All packages finished")) + @Expose def notify(self, event, msg=""): apikey = self.getConfig("apikey") if not apikey: - return False + return + + if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + return + + elapsed_time = time.time() - self.last_notify + + if elapsed_time < self.getConf("sendtimewait"): + return + + if elapsed_time > 60: + self.notifications = 0 + + elif self.notifications >= self.getConf("sendpermin"): + return - if self.core.isClientConnected() and not self.getConfig("force"): - return False getURL("http://www.notifymyandroid.com/publicapi/notify", get={'apikey' : apikey, @@ -77,4 +89,5 @@ class AndroidPhoneNotify(Hook): 'event' : event, 'description': msg}) - self.last_notify = time() + self.last_notify = time.time() + self.notifications += 1 diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index e0dd75f92..010198bf1 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -1,29 +1,29 @@ # -*- coding: utf-8 -*- import httplib +import time -from time import time - -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, Expose class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify processed packages status" , True ), - ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), - ("force" , "bool", "Send notifications if client is connected", False)] + ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), + ("sendpermin" , "int" , "Max notifications per minute" , 12 ), + ("ignoreclient" , "bool", "Send notifications if client is connected", False)] __description__ = """Send push notifications to Windows Phone""" __license__ = "GPLv3" - __authors__ = [("Andy Voigt", "phone-support@hotmail.de"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Andy Voigt" , "phone-support@hotmail.de"), + ("Walter Purcaro", "vuolter@gmail.com" )] event_list = ["allDownloadsProcessed"] @@ -35,16 +35,14 @@ class WindowsPhoneNotify(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.last_notify = 0 + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 + self.notifications = 0 def newCaptchaTask(self, task): if not self.getConfig("notifycaptcha"): - return False - - if time() - self.last_notify < self.getConf("timeout"): - return False + return self.notify(_("Captcha"), _("New request waiting user input")) @@ -56,7 +54,7 @@ class WindowsPhoneNotify(Hook): def allDownloadsProcessed(self): if not self.getConfig("notifyprocessed"): - return False + return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): self.notify(_("Package failed"), _("One or more packages was not completed successfully")) @@ -70,15 +68,28 @@ class WindowsPhoneNotify(Hook): " " % msg) + @Expose def notify(self, event, msg=""): id = self.getConfig("id") url = self.getConfig("url") if not id or not url: - return False + return + + if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + return + + elapsed_time = time.time() - self.last_notify + + if elapsed_time < self.getConf("sendtimewait"): + return + + if elapsed_time > 60: + self.notifications = 0 + + elif self.notifications >= self.getConf("sendpermin"): + return - if self.core.isClientConnected() and not self.getConfig("force"): - return False request = self.getXmlData("%s: %s" % (event, msg) if msg else event) webservice = httplib.HTTP(url) @@ -93,4 +104,5 @@ class WindowsPhoneNotify(Hook): webservice.send(request) webservice.close() - self.last_notify = time() + self.last_notify = time.time() + self.notifications += 1 -- cgit v1.2.3 From 6f7002bcc3520c47fafe5122b0e0cbada313887d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 23:39:59 +0100 Subject: Whitespace cosmetics --- module/plugins/hooks/BypassCaptcha.py | 4 ++-- module/plugins/hooks/Captcha9Kw.py | 2 +- module/plugins/hooks/CaptchaBrotherhood.py | 2 +- module/plugins/hooks/Checksum.py | 6 +++--- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/DeathByCaptcha.py | 2 +- module/plugins/hooks/DebridItaliaCom.py | 4 ++-- module/plugins/hooks/ExpertDecoders.py | 2 +- module/plugins/hooks/ExternalScripts.py | 8 ++++---- module/plugins/hooks/ImageTyperz.py | 2 +- module/plugins/hooks/JustPremium.py | 6 +++--- module/plugins/hooks/PremiumTo.py | 2 +- module/plugins/hooks/ZeveraCom.py | 4 ++-- 13 files changed, 23 insertions(+), 23 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index cf8754dae..777564554 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -35,9 +35,9 @@ class BypassCaptcha(Hook): __description__ = """Send captchas to BypassCaptcha.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("Godofdream", "soilfcition@gmail.com"), - ("zoidberg", "zoidberg@mujmail.cz")] + ("zoidberg" , "zoidberg@mujmail.cz" )] PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32" diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 544965b0f..2b4f405ed 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -32,7 +32,7 @@ class Captcha9Kw(Hook): __description__ = """Send captchas to 9kw.eu""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 3c08f5e36..478138c3b 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -46,7 +46,7 @@ class CaptchaBrotherhood(Hook): __description__ = """Send captchas to CaptchaBrotherhood.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 064375a41..7d08e6552 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -50,9 +50,9 @@ class Checksum(Hook): __description__ = """Verify downloaded file size and checksum""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com"), - ("stickell", "l.stickell@yahoo.it")] + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com" ), + ("stickell" , "l.stickell@yahoo.it")] methods = {'sfv' : 'crc32', diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 938269795..2f5938101 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -32,7 +32,7 @@ class ClickAndLoad(Hook): __description__ = """Click'n'Load hook plugin""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.de"), + __authors__ = [("RaNaN" , "RaNaN@pyload.de" ), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index d513c446d..a67e70c7e 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -59,7 +59,7 @@ class DeathByCaptcha(Hook): __description__ = """Send captchas to DeathByCaptcha.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py index 719f3dd3a..399f6462f 100644 --- a/module/plugins/hooks/DebridItaliaCom.py +++ b/module/plugins/hooks/DebridItaliaCom.py @@ -20,8 +20,8 @@ class DebridItaliaCom(MultiHook): __description__ = """Debriditalia.com hook plugin""" __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("stickell" , "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com" )] def getHosters(self): diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index c9f8204c4..d6ecca680 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -21,7 +21,7 @@ class ExpertDecoders(Hook): __description__ = """Send captchas to expertdecoders.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 76444d4b3..14387e234 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -17,9 +17,9 @@ class ExternalScripts(Hook): __description__ = """Run external scripts""" __license__ = "GPLv3" - __authors__ = [("mkaay", "mkaay@mkaay.de"), - ("RaNaN", "ranan@pyload.org"), - ("spoob", "spoob@pyload.org"), + __authors__ = [("mkaay" , "mkaay@mkaay.de" ), + ("RaNaN" , "ranan@pyload.org" ), + ("spoob" , "spoob@pyload.org" ), ("Walter Purcaro", "vuolter@gmail.com")] @@ -67,7 +67,7 @@ class ExternalScripts(Hook): if not os.path.isfile(file): continue - + if filename[0] in ("#", "_") or filename.endswith("~") or filename.endswith(".swp"): continue diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index d62fed385..b9dbfcdbe 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -40,7 +40,7 @@ class ImageTyperz(Hook): __description__ = """Send captchas to ImageTyperz.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index daefbc30f..3064743e2 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -15,9 +15,9 @@ class JustPremium(Hook): __description__ = """Remove not-premium links from added urls""" __license__ = "GPLv3" - __authors__ = [("mazleu", "mazleica@gmail.com"), - ("Walter Purcaro", "vuolter@gmail.com"), - ("immenz", "immenz@gmx.net")] + __authors__ = [("mazleu" , "mazleica@gmail.com"), + ("Walter Purcaro", "vuolter@gmail.com" ), + ("immenz" , "immenz@gmx.net" )] event_list = ["linksAdded"] diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index b629b111e..250125016 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -18,7 +18,7 @@ class PremiumTo(MultiHook): __description__ = """Premium.to hook plugin""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz"), ("stickell", "l.stickell@yahoo.it")] diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index 215ec3673..33c49d8be 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -18,8 +18,8 @@ class ZeveraCom(MultiHook): __description__ = """Zevera.com hook plugin""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com" )] def getHosters(self): -- cgit v1.2.3 From 04f2d0f9a377fcbabebd99c98ffc0638459acd6d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 9 Mar 2015 04:06:15 +0100 Subject: [ExternalScripts] Fixup --- module/plugins/hooks/ExternalScripts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 14387e234..5f2790656 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.31" + __version__ = "0.32" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -79,11 +79,11 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] + cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) - p = subprocess.Popen([script, fs_encode(cmd)], bufsize=-1) #@NOTE: output goes to pyload + p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload if self.getConfig('waitend'): p.communicate() @@ -99,8 +99,8 @@ class ExternalScripts(Hook): def downloadFinished(self, pyfile): download_folder = self.config['general']['download_folder'] for script in self.scripts['download_finished']: - filename = save_join(download_folder, pyfile.package().folder, pyfile.name) - self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, filename, pyfile.id) + file = save_join(download_folder, pyfile.package().folder, pyfile.name) + self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, file, pyfile.id) def packageFinished(self, pypack): -- cgit v1.2.3 From 164ff94bd87b8b0de3c872b0b60153ac5abfad4b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 9 Mar 2015 23:26:18 +0100 Subject: [ExtractArchive] Fix https://github.com/pyload/pyload/issues/1241 --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 6a25602e8..edf25b8c7 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -108,7 +108,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.32" + __version__ = "1.33" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -474,7 +474,7 @@ class ExtractArchive(Hook): print_exc() finally: - pyfile.finishIfDone() + thread.finishFile(pyfile) self.manager.dispatchEvent("archive_extract_failed", pyfile) -- cgit v1.2.3 From f85e28e565a1e0a76e6271d0b0853d6d48b4a043 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 01:16:29 +0100 Subject: [MultiHook] Fix _pluginSet (fix LinkdecrypterCom issue) --- module/plugins/hooks/LinkdecrypterCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index f85a598bc..769e63e81 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -8,7 +8,7 @@ from module.plugins.internal.MultiHook import MultiHook class LinkdecrypterCom(MultiHook): __name__ = "LinkdecrypterCom" __type__ = "hook" - __version__ = "1.02" + __version__ = "1.03" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -22,4 +22,4 @@ class LinkdecrypterCom(MultiHook): def getCrypters(self): return re.search(r'>Supported\(\d+\): (.[\w.\-, ]+)', - self.getURL("http://linkdecrypter.com/").replace("(g)", "")).group(1).split(', ') + self.getURL("http://linkdecrypter.com/", decode=True).replace("(g)", "")).group(1).split(', ') -- cgit v1.2.3 From 7beb65e991bc6d1913c3b5bb2ef69e659d5b8342 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 01:55:52 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/AlldebridCom.py | 2 +- module/plugins/hooks/AndroidPhoneNotify.py | 18 ++++++++------- module/plugins/hooks/AntiVirus.py | 7 +++--- module/plugins/hooks/BypassCaptcha.py | 10 ++++----- module/plugins/hooks/Captcha9Kw.py | 36 +++++++++++++++--------------- module/plugins/hooks/CaptchaBrotherhood.py | 14 ++++++------ module/plugins/hooks/Checksum.py | 12 +++++----- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/DeathByCaptcha.py | 10 ++++----- module/plugins/hooks/DownloadScheduler.py | 4 ++-- module/plugins/hooks/ExpertDecoders.py | 10 ++++----- module/plugins/hooks/ExternalScripts.py | 19 ++++++++-------- module/plugins/hooks/HotFolder.py | 8 +++---- module/plugins/hooks/IRCInterface.py | 22 +++++++++--------- module/plugins/hooks/ImageTyperz.py | 18 +++++++-------- module/plugins/hooks/MultiHome.py | 2 +- module/plugins/hooks/OverLoadMe.py | 2 +- module/plugins/hooks/RealdebridCom.py | 2 +- module/plugins/hooks/RestartFailed.py | 8 +++---- module/plugins/hooks/RestartSlow.py | 4 ++-- module/plugins/hooks/SkipRev.py | 22 +++++++++--------- module/plugins/hooks/UnSkipOnFail.py | 2 +- module/plugins/hooks/UpdateManager.py | 16 ++++++------- module/plugins/hooks/WindowsPhoneNotify.py | 17 ++++++++------ module/plugins/hooks/XFileSharingPro.py | 14 ++++++------ module/plugins/hooks/XMPPInterface.py | 14 ++++++------ 26 files changed, 150 insertions(+), 145 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index fd89571eb..517adcb68 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -23,7 +23,7 @@ class AlldebridCom(MultiHook): def getHosters(self): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" html = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 7a9e6d6f8..180ad0d78 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -40,19 +40,19 @@ class AndroidPhoneNotify(Hook): def newCaptchaTask(self, task): - if not self.getConfig("notifycaptcha"): + if not self.getConfig('notifycaptcha'): return self.notify(_("Captcha"), _("New request waiting user input")) def packageFinished(self, pypack): - if self.getConfig("notifypackage"): + if self.getConfig('notifypackage'): self.notify(_("Package finished"), pypack.name) def allDownloadsProcessed(self): - if not self.getConfig("notifyprocessed"): + if not self.getConfig('notifyprocessed'): return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): @@ -62,13 +62,15 @@ class AndroidPhoneNotify(Hook): @Expose - def notify(self, event, msg=""): - apikey = self.getConfig("apikey") + def notify(self, + event, + msg="", + key=self.getConfig('apikey')): - if not apikey: + if not key: return - if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + if self.core.isClientConnected() and not self.getConfig('ignoreclient'): return elapsed_time = time.time() - self.last_notify @@ -84,7 +86,7 @@ class AndroidPhoneNotify(Hook): getURL("http://www.notifymyandroid.com/publicapi/notify", - get={'apikey' : apikey, + get={'apikey' : key, 'application': "pyLoad", 'event' : event, 'description': msg}) diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 695852683..b8a659f99 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -13,7 +13,7 @@ class AntiVirus(Hook): __type__ = "hook" __version__ = "0.04" - __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), #@TODO: add trash option (use Send2Trash lib) ("quardir" , "folder" , "Quarantine folder" , "" ), ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), ("cmdfile" , "file" , "Antivirus executable" , "" ), @@ -55,7 +55,7 @@ class AntiVirus(Hook): if err: self.logWarning(filename, err) if not self.getConfig('ignore-err') - self.logDebug("Delete/Quarantine action aborted") + self.logDebug("Delete/Quarantine task is aborted") return if p.returncode: @@ -68,8 +68,7 @@ class AntiVirus(Hook): elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) pyfile.setProgress(0) - new_filename = save_join(self.getConfig('quardir'), filename) - shutil.move(file, new_filename) + shutil.move(file, self.getConfig('quardir')) except (IOError, shutil.Error), e: self.logError(filename, action + " action failed!", e) diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 777564554..d7995650b 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -57,7 +57,7 @@ class BypassCaptcha(Hook): def getCredits(self): - res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")}) + res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig('passkey')}) data = dict(x.split(' ', 1) for x in res.splitlines()) return int(data['Left']) @@ -72,7 +72,7 @@ class BypassCaptcha(Hook): try: res = req.load(self.SUBMIT_URL, post={'vendor_key': self.PYLOAD_KEY, - 'key': self.getConfig("passkey"), + 'key': self.getConfig('passkey'), 'gen_task_id': "1", 'file': (FORM_FILE, captcha)}, multipart=True) @@ -92,7 +92,7 @@ class BypassCaptcha(Hook): def respond(self, ticket, success): try: - res = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig("passkey"), + res = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig('passkey'), "cv": 1 if success else 0}) except BadHeader, e: self.logError(_("Could not send response"), e) @@ -105,10 +105,10 @@ class BypassCaptcha(Hook): if not task.isTextual(): return False - if not self.getConfig("passkey"): + if not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 0: diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 2b4f405ed..6d42416ff 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -46,13 +46,13 @@ class Captcha9Kw(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - if self.getConfig("ssl"): + if self.getConfig('ssl'): self.API_URL = self.API_URL.replace("http://", "https://") def getCredits(self): res = getURL(self.API_URL, - get={'apikey': self.getConfig("passkey"), + get={'apikey': self.getConfig('passkey'), 'pyload': "1", 'source': "pyload", 'action': "usercaptchaguthaben"}) @@ -83,14 +83,14 @@ class Captcha9Kw(Hook): 'numeric' : 0, 'case_sensitive': 0, 'math' : 0, - 'prio' : min(max(self.getConfig("prio"), 0), 10), - 'confirm' : self.getConfig("confirm"), - 'timeout' : min(max(self.getConfig("timeout"), 300), 3999), - 'selfsolve' : self.getConfig("selfsolve"), - 'cph' : self.getConfig("captchaperhour"), - 'cpm' : self.getConfig("captchapermin")} + 'prio' : min(max(self.getConfig('prio'), 0), 10), + 'confirm' : self.getConfig('confirm'), + 'timeout' : min(max(self.getConfig('timeout'), 300), 3999), + 'selfsolve' : self.getConfig('selfsolve'), + 'cph' : self.getConfig('captchaperhour'), + 'cpm' : self.getConfig('captchapermin')} - for opt in str(self.getConfig("hoster_options").split('|')): + for opt in str(self.getConfig('hoster_options').split('|')): details = map(str.strip, opt.split(':')) @@ -109,7 +109,7 @@ class Captcha9Kw(Hook): break - post_data = {'apikey' : self.getConfig("passkey"), + post_data = {'apikey' : self.getConfig('passkey'), 'prio' : option['prio'], 'confirm' : option['confirm'], 'maxtimeout' : option['timeout'], @@ -146,9 +146,9 @@ class Captcha9Kw(Hook): task.data["ticket"] = res - for _i in xrange(int(self.getConfig("timeout") / 5)): + for _i in xrange(int(self.getConfig('timeout') / 5)): result = getURL(self.API_URL, - get={'apikey': self.getConfig("passkey"), + get={'apikey': self.getConfig('passkey'), 'id' : res, 'pyload': "1", 'info' : "1", @@ -172,10 +172,10 @@ class Captcha9Kw(Hook): if not task.isTextual() and not task.isPositional(): return - if not self.getConfig("passkey"): + if not self.getConfig('passkey'): return - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return credits = self.getCredits() @@ -184,8 +184,8 @@ class Captcha9Kw(Hook): self.logError(_("Your captcha 9kw.eu account has not enough credits")) return - queue = min(self.getConfig("queue"), 999) - timeout = min(max(self.getConfig("timeout"), 300), 3999) + queue = min(self.getConfig('queue'), 999) + timeout = min(max(self.getConfig('timeout'), 300), 3999) pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1) for _i in xrange(5): @@ -197,7 +197,7 @@ class Captcha9Kw(Hook): else: self.fail(_("Too many captchas in queue")) - for opt in str(self.getConfig("hoster_options").split('|')): + for opt in str(self.getConfig('hoster_options').split('|')): details = map(str.strip, opt.split(':')) if not details or details[0].lower() != pluginname.lower(): @@ -227,7 +227,7 @@ class Captcha9Kw(Hook): self.logDebug("No CaptchaID for %s request (task: %s)" % (type, task)) return - passkey = self.getConfig("passkey") + passkey = self.getConfig('passkey') for _i in xrange(3): res = getURL(self.API_URL, diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 478138c3b..5350b4f7d 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -64,7 +64,7 @@ class CaptchaBrotherhood(Hook): def getCredits(self): res = getURL(self.API_URL + "askCredits.aspx", - get={"username": self.getConfig("username"), "password": self.getConfig("passkey")}) + get={"username": self.getConfig('username'), "password": self.getConfig('passkey')}) if not res.startswith("OK"): raise CaptchaBrotherhoodException(res) else: @@ -93,8 +93,8 @@ class CaptchaBrotherhood(Hook): req = getRequest() url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL, - urlencode({'username' : self.getConfig("username"), - 'password' : self.getConfig("passkey"), + urlencode({'username' : self.getConfig('username'), + 'password' : self.getConfig('passkey'), 'captchaSource': "pyLoad", 'timeout' : "80"})) @@ -127,8 +127,8 @@ class CaptchaBrotherhood(Hook): def api_response(self, api, ticket): res = getURL("%s%s.aspx" % (self.API_URL, api), - get={"username": self.getConfig("username"), - "password": self.getConfig("passkey"), + get={"username": self.getConfig('username'), + "password": self.getConfig('passkey'), "captchaID": ticket}) if not res.startswith("OK"): raise CaptchaBrotherhoodException("Unknown response: %s" % res) @@ -143,10 +143,10 @@ class CaptchaBrotherhood(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 10: diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 7d08e6552..9474f6968 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -70,7 +70,7 @@ class Checksum(Hook): def coreReady(self): - if not self.getConfig("check_checksum"): + if not self.getConfig('check_checksum'): self.logInfo(_("Checksum validation is disabled in plugin configuration")) @@ -125,7 +125,7 @@ class Checksum(Hook): data.pop('size', None) # validate checksum - if data and self.getConfig("check_checksum"): + if data and self.getConfig('check_checksum'): if not 'md5' in data: for type in ("checksum", "hashsum", "hash"): @@ -152,14 +152,14 @@ class Checksum(Hook): def checkFailed(self, pyfile, local_file, msg): - check_action = self.getConfig("check_action") + check_action = self.getConfig('check_action') if check_action == "retry": - max_tries = self.getConfig("max_tries") - retry_action = self.getConfig("retry_action") + max_tries = self.getConfig('max_tries') + retry_action = self.getConfig('retry_action') if pyfile.plugin.retries < max_tries: if local_file: remove(local_file) - pyfile.plugin.retry(max_tries, self.getConfig("wait_time"), msg) + pyfile.plugin.retry(max_tries, self.getConfig('wait_time'), msg) elif retry_action == "nothing": return elif check_action == "nothing": diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 2f5938101..731c8bd7e 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -45,7 +45,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = "" if self.getConfig("extern") else "127.0.0.1" + ip = "" if self.getConfig('extern') else "127.0.0.1" webport = self.config['webinterface']['port'] cnlport = self.getConfig('port') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index a67e70c7e..4eefb2bff 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -82,8 +82,8 @@ class DeathByCaptcha(Hook): if post: if not isinstance(post, dict): post = {} - post.update({"username": self.getConfig("username"), - "password": self.getConfig("passkey")}) + post.update({"username": self.getConfig('username'), + "password": self.getConfig('passkey')}) res = None try: @@ -136,7 +136,7 @@ class DeathByCaptcha(Hook): def submit(self, captcha, captchaType="file", match=None): #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.getConfig("passkey")): + if re.match("^\w*$", self.getConfig('passkey')): multipart = True data = (FORM_FILE, captcha) else: @@ -172,10 +172,10 @@ class DeathByCaptcha(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False try: diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 4996e212d..3b7ae524c 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -37,7 +37,7 @@ class DownloadScheduler(Hook): def updateSchedule(self, schedule=None): if schedule is None: - schedule = self.getConfig("timetable") + schedule = self.getConfig('timetable') schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", schedule.lower().replace("full", "-1").replace("none", "0")) @@ -65,7 +65,7 @@ class DownloadScheduler(Hook): def setDownloadSpeed(self, speed): if speed == 0: - abort = self.getConfig("abort") + abort = self.getConfig('abort') self.logInfo(_("Stopping download server. (Running downloads will %sbe aborted.)") % '' if abort else _('not ')) self.core.api.pauseServer() if abort: diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index d6ecca680..fa1c7a14b 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -38,7 +38,7 @@ class ExpertDecoders(Hook): def getCredits(self): - res = getURL(self.API_URL, post={"key": self.getConfig("passkey"), "action": "balance"}) + res = getURL(self.API_URL, post={"key": self.getConfig('passkey'), "action": "balance"}) if res.isdigit(): self.logInfo(_("%s credits left") % res) @@ -64,7 +64,7 @@ class ExpertDecoders(Hook): try: result = req.load(self.API_URL, post={'action' : "upload", - 'key' : self.getConfig("passkey"), + 'key' : self.getConfig('passkey'), 'file' : b64encode(data), 'gen_task_id': ticket}) finally: @@ -78,10 +78,10 @@ class ExpertDecoders(Hook): if not task.isTextual(): return False - if not self.getConfig("passkey"): + if not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 0: @@ -98,7 +98,7 @@ class ExpertDecoders(Hook): try: res = getURL(self.API_URL, - post={'action': "refund", 'key': self.getConfig("passkey"), 'gen_task_id': task.data['ticket']}) + post={'action': "refund", 'key': self.getConfig('passkey'), 'gen_task_id': task.data['ticket']}) self.logInfo(_("Request refund"), res) except BadHeader, e: diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 5f2790656..d17e4740c 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -44,26 +44,25 @@ class ExternalScripts(Hook): for folder in folders: self.scripts[folder] = [] - - self.initPluginType(folder, os.path.join(pypath, 'scripts', folder)) - self.initPluginType(folder, os.path.join('scripts', folder)) + for dir in (pypath, ''): + self.initPluginType(folder, os.path.join(dir, 'scripts', folder)) for script_type, names in self.scripts.iteritems(): if names: self.logInfo(_("Installed scripts for ") + script_type, ", ".join(map(os.path.basename, names))) - def initPluginType(self, folder, path): - if not os.path.exists(path): + def initPluginType(self, name, dir): + if not os.path.isdir(dir): try: - os.makedirs(path) + os.makedirs(dir) except IOError, e: self.logDebug(e) return - for filename in os.listdir(path): - file = os.path.join(path, filename) + for filename in os.listdir(dir): + file = os.path.join(dir, filename) if not os.path.isfile(file): continue @@ -72,9 +71,9 @@ class ExternalScripts(Hook): continue if not os.access(file, os.X_OK): - self.logWarning(_("Script not executable:") + " %s/%s" % (folder, filename)) + self.logWarning(_("Script not executable:") + " %s/%s" % (name, filename)) - self.scripts[folder].append(file) + self.scripts[name].append(file) def callScript(self, script, *args): diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 302bc909f..a046e55e7 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -31,14 +31,14 @@ class HotFolder(Hook): def periodical(self): - folder = fs_encode(self.getConfig("folder")) - file = fs_encode(self.getConfig("file")) + folder = fs_encode(self.getConfig('folder')) + file = fs_encode(self.getConfig('file')) try: if not os.path.isdir(os.path.join(folder, "finished")): os.makedirs(os.path.join(folder, "finished")) - if self.getConfig("watch_file"): + if self.getConfig('watch_file'): with open(file, "a+") as f: f.seek(0) content = f.read().strip() @@ -60,7 +60,7 @@ class HotFolder(Hook): if not os.path.isfile(path) or f.endswith("~") or f.startswith("#") or f.startswith("."): continue - newpath = os.path.join(folder, "finished", f if self.getConfig("keep") else "tmp_" + f) + newpath = os.path.join(folder, "finished", f if self.getConfig('keep') else "tmp_" + f) move(path, newpath) self.logInfo(_("Added %s from HotFolder") % f) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 623f2d1bf..1c90c0e2f 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -59,7 +59,7 @@ class IRCInterface(Thread, Hook): def packageFinished(self, pypack): try: - if self.getConfig("info_pack"): + if self.getConfig('info_pack'): self.response(_("Package finished: %s") % pypack.name) except Exception: pass @@ -67,7 +67,7 @@ class IRCInterface(Thread, Hook): def downloadFinished(self, pyfile): try: - if self.getConfig("info_file"): + if self.getConfig('info_file'): self.response( _("Download finished: %(name)s @ %(plugin)s ") % {"name": pyfile.name, "plugin": pyfile.pluginname}) except Exception: @@ -75,7 +75,7 @@ class IRCInterface(Thread, Hook): def newCaptchaTask(self, task): - if self.getConfig("captcha") and task.isTextual(): + if self.getConfig('captcha') and task.isTextual(): task.handler.append(self) task.setWaiting(60) @@ -90,16 +90,16 @@ class IRCInterface(Thread, Hook): def run(self): # connect to IRC etc. self.sock = socket.socket() - host = self.getConfig("host") - self.sock.connect((host, self.getConfig("port"))) + host = self.getConfig('host') + self.sock.connect((host, self.getConfig('port'))) - if self.getConfig("ssl"): + if self.getConfig('ssl'): self.sock = ssl.wrap_socket(self.sock, cert_reqs=ssl.CERT_NONE) #@TODO: support certificate - nick = self.getConfig("nick") + nick = self.getConfig('nick') self.sock.send("NICK %s\r\n" % nick) self.sock.send("USER %s %s bla :%s\r\n" % (nick, host, nick)) - for t in self.getConfig("owner").split(): + for t in self.getConfig('owner').split(): if t.strip().startswith("#"): self.sock.send("JOIN %s\r\n" % t.strip()) self.logInfo(_("Connected to"), host) @@ -153,10 +153,10 @@ class IRCInterface(Thread, Hook): 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": @@ -197,7 +197,7 @@ class IRCInterface(Thread, Hook): def response(self, msg, origin=""): if origin == "": - for t in self.getConfig("owner").split(): + for t in self.getConfig('owner').split(): self.sock.send("PRIVMSG %s :%s\r\n" % (t.strip(), msg)) else: self.sock.send("PRIVMSG %s :%s\r\n" % (origin.split("!", 1)[0], msg)) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index b9dbfcdbe..2cf611b9f 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -61,8 +61,8 @@ class ImageTyperz(Hook): def getCredits(self): res = getURL(self.GETCREDITS_URL, post={'action': "REQUESTBALANCE", - 'username': self.getConfig("username"), - 'password': self.getConfig("passkey")}) + 'username': self.getConfig('username'), + 'password': self.getConfig('passkey')}) if res.startswith('ERROR'): raise ImageTyperzException(res) @@ -83,7 +83,7 @@ class ImageTyperz(Hook): try: #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.getConfig("passkey")): + if re.match("^\w*$", self.getConfig('passkey')): multipart = True data = (FORM_FILE, captcha) else: @@ -94,8 +94,8 @@ class ImageTyperz(Hook): res = req.load(self.SUBMIT_URL, post={'action': "UPLOADCAPTCHA", - 'username': self.getConfig("username"), - 'password': self.getConfig("passkey"), "file": data}, + 'username': self.getConfig('username'), + 'password': self.getConfig('passkey'), "file": data}, multipart=multipart) finally: req.close() @@ -119,10 +119,10 @@ class ImageTyperz(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 0: @@ -139,8 +139,8 @@ class ImageTyperz(Hook): if task.data['service'] == self.__name__ and "ticket" in task.data: res = getURL(self.RESPOND_URL, post={'action': "SETBADIMAGE", - 'username': self.getConfig("username"), - 'password': self.getConfig("passkey"), + 'username': self.getConfig('username'), + 'password': self.getConfig('passkey'), 'imageid': task.data['ticket']}) if res == "SUCCESS": diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index c9f6fc30c..9093c8459 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -25,7 +25,7 @@ class MultiHome(Hook): def setup(self): self.register = {} self.interfaces = [] - self.parseInterfaces(self.getConfig("interfaces").split(";")) + self.parseInterfaces(self.getConfig('interfaces').split(";")) if not self.interfaces: self.parseInterfaces([self.config['download']['interface']]) self.setConfig("interfaces", self.toConfig()) diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index b15ce2766..5e1040da7 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -23,7 +23,7 @@ class OverLoadMe(MultiHook): def getHosters(self): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" html = self.getURL(https + "://api.over-load.me/hoster.php", get={'auth': "0001-cb1f24dadb3aa487bda5afd3b76298935329be7700cd7-5329be77-00cf-1ca0135f"}).replace("\"", "").strip() self.logDebug("Hosterlist", html) diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index d9c9407dd..c97bc257c 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -23,7 +23,7 @@ class RealdebridCom(MultiHook): def getHosters(self): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" html = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 07fb80967..7752b6a61 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -17,13 +17,13 @@ class RestartFailed(Hook): # event_list = ["pluginConfigChanged"] - MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) + MIN_CHECK_INTERVAL = 15 * 60 #: 15 minutes def pluginConfigChanged(self, plugin, name, value): if name == "interval": interval = value * 60 - if self.MIN_INTERVAL <= interval != self.interval: + if self.MIN_CHECK_INTERVAL <= interval != self.interval: self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() @@ -37,8 +37,8 @@ class RestartFailed(Hook): def setup(self): - self.interval = self.MIN_INTERVAL + self.interval = self.MIN_CHECK_INTERVAL def coreReady(self): - self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) + self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) diff --git a/module/plugins/hooks/RestartSlow.py b/module/plugins/hooks/RestartSlow.py index c3e1e5468..834128489 100644 --- a/module/plugins/hooks/RestartSlow.py +++ b/module/plugins/hooks/RestartSlow.py @@ -36,7 +36,7 @@ class RestartSlow(Hook): if not self.pyfile.plugin.req.dl: return - if self.getConfig("safe_mode") and not self.pyfile.plugin.resumeDownload: + if self.getConfig('safe_mode') and not self.pyfile.plugin.resumeDownload: time = 30 limit = 5 else: @@ -55,7 +55,7 @@ class RestartSlow(Hook): def downloadStarts(self, pyfile, url, filename): - if self.cb or (self.getConfig("safe_mode") and not pyfile.plugin.resumeDownload): + if self.cb or (self.getConfig('safe_mode') and not pyfile.plugin.resumeDownload): return self.pyfile = pyfile super(RestartSlow, self).initPeriodical() diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 521c2c39e..88ffb0103 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -11,16 +11,10 @@ from module.plugins.Hook import Hook from module.plugins.Plugin import SkipDownload -def _setup(self): - self.pyfile.plugin._setup() - if self.pyfile.hasStatus("skipped"): - raise SkipDownload(self.pyfile.statusname or self.pyfile.pluginname) - - class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.28" + __version__ = "0.29" __config__ = [("mode" , "Auto;Manual", "Choose rev files to skip for package", "Auto"), ("revtokeep", "int" , "Number of rev files to keep" , 0 )] @@ -35,6 +29,13 @@ class SkipRev(Hook): pass + @staticmethod + def _setup(self): + self.pyfile.plugin._setup() + if self.pyfile.hasStatus("skipped"): + raise SkipDownload(self.pyfile.statusname or self.pyfile.pluginname) + + def _name(self, pyfile): if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] @@ -59,7 +60,7 @@ class SkipRev(Hook): def downloadPreparing(self, pyfile): name = self._name(pyfile) - if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not ".part" in name: + if pyfile.statusname is _("unskipped") or not name.endswith(".rev") or not ".part" in name: return revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') @@ -77,8 +78,9 @@ class SkipRev(Hook): pyfile.setCustomStatus("SkipRev", "skipped") if not hasattr(pyfile.plugin, "_setup"): + # Work-around: inject status checker inside the preprocessing routine of the plugin pyfile.plugin._setup = pyfile.plugin.setup - pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin + pyfile.plugin.setup = MethodType(self._setup, pyfile.plugin) def downloadFailed(self, pyfile): @@ -101,7 +103,7 @@ class SkipRev(Hook): if revtokeep > -1 or pyfile.name.endswith(".rev"): pylink.setStatus("queued") else: - pylink.setCustomStatus("unskipped", "queued") + pylink.setCustomStatus(_("unskipped"), "queued") self.core.files.save() pylink.release() diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 1becb937a..7a5ae8e09 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -43,7 +43,7 @@ class UnSkipOnFail(Hook): # the core.files-manager to save its data. pylink = _pyfile(link) - pylink.setCustomStatus("UnSkipOnFail", "queued") + pylink.setCustomStatus(_("unskipped"), "queued") self.core.files.save() pylink.release() diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index a0b044edb..45d666f45 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -46,13 +46,13 @@ class UpdateManager(Hook): SERVER_URL = "http://updatemanager.pyload.org" VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') - MIN_INTERVAL = 3 * 60 * 60 #: 3h minimum check interval (value is in seconds) + MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours def pluginConfigChanged(self, plugin, name, value): if name == "interval": interval = value * 60 * 60 - if self.MIN_INTERVAL <= interval != self.interval: + if self.MIN_CHECK_INTERVAL <= interval != self.interval: self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() @@ -67,8 +67,8 @@ class UpdateManager(Hook): def coreReady(self): - self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) - x = lambda: self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig("reloadplugins")) + self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) + x = lambda: self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig('reloadplugins')) self.core.scheduler.addJob(10, x, threaded=False) @@ -78,7 +78,7 @@ class UpdateManager(Hook): def setup(self): self.cb2 = None - self.interval = self.MIN_INTERVAL + self.interval = self.MIN_CHECK_INTERVAL self.updating = False self.info = {'pyload': False, 'version': None, 'plugins': False} self.mtimes = {} #: store modification time for each plugin @@ -122,7 +122,7 @@ class UpdateManager(Hook): 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.updateThread() @@ -138,9 +138,9 @@ class UpdateManager(Hook): def updateThread(self): self.updating = True - status = self.update(onlyplugin=self.getConfig("mode") == "plugins only") + status = self.update(onlyplugin=self.getConfig('mode') == "plugins only") - if status is 2 and self.getConfig("autorestart"): + if status is 2 and self.getConfig('autorestart'): self.core.api.restart() else: self.updating = False diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index 010198bf1..a1068ead5 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -41,19 +41,19 @@ class WindowsPhoneNotify(Hook): def newCaptchaTask(self, task): - if not self.getConfig("notifycaptcha"): + if not self.getConfig('notifycaptcha'): return self.notify(_("Captcha"), _("New request waiting user input")) def packageFinished(self, pypack): - if self.getConfig("notifypackage"): + if self.getConfig('notifypackage'): self.notify(_("Package finished"), pypack.name) def allDownloadsProcessed(self): - if not self.getConfig("notifyprocessed"): + if not self.getConfig('notifyprocessed'): return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): @@ -69,14 +69,17 @@ class WindowsPhoneNotify(Hook): @Expose - def notify(self, event, msg=""): - id = self.getConfig("id") - url = self.getConfig("url") + def notify(self, + event, + msg="", + key=(self.getConfig('id'), self.getConfig('url'))): + + id, url = key if not id or not url: return - if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + if self.core.isClientConnected() and not self.getConfig('ignoreclient'): return elapsed_time = time.time() - self.last_notify diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 495140652..d9552051e 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.32" + __version__ = "0.33" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -23,15 +23,15 @@ class XFileSharingPro(Hook): # event_list = ["pluginConfigChanged"] - regexp = {'hoster' : (r'https?://(?:www\.)?(?P[\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', + regexp = {'hoster' : (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P%s)/(?:embed-)?\w+'), - 'crypter': (r'https?://(?:www\.)?(?P[\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', + 'crypter': (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', r'https?://(?:[^/]+\.)?(?P%s)/(?:user|folder)s?/\w+')} HOSTER_BUILTIN = [#WORKING HOSTERS: - "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", - "fileparadox.in", "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", - "ryushare.com", "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", + "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", + "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", "ryushare.com", + "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", #NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", @@ -126,7 +126,7 @@ class XFileSharingPro(Hook): # def downloadFailed(self, pyfile): # if pyfile.pluginname == "BasePlugin" \ # and pyfile.hasStatus("failed") \ - # and not self.getConfig("use_hoster_list") \ + # and not self.getConfig('use_hoster_list') \ # and self.unloadHoster("BasePlugin"): # self.logDebug("Unloaded XFileSharingPro from BasePlugin") # pyfile.setStatus("queued") diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index b8e9fc1ad..b61428392 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -33,14 +33,14 @@ class XMPPInterface(IRCInterface, JabberClient): def __init__(self, core, manager): IRCInterface.__init__(self, core, manager) - self.jid = JID(self.getConfig("jid")) - password = self.getConfig("pw") + self.jid = JID(self.getConfig('jid')) + password = self.getConfig('pw') # if bare JID is provided add a resource -- it is required if not self.jid.resource: self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") - if self.getConfig("tls"): + if self.getConfig('tls'): tls_settings = streamtls.TLSSettings(require=True, verify_peer=False) auth = ("sasl:PLAIN", "sasl:DIGEST-MD5") else: @@ -67,7 +67,7 @@ class XMPPInterface(IRCInterface, JabberClient): def packageFinished(self, pypack): try: - if self.getConfig("info_pack"): + if self.getConfig('info_pack'): self.announce(_("Package finished: %s") % pypack.name) except Exception: pass @@ -75,7 +75,7 @@ class XMPPInterface(IRCInterface, JabberClient): def downloadFinished(self, pyfile): try: - if self.getConfig("info_file"): + if self.getConfig('info_file'): self.announce( _("Download finished: %(name)s @ %(plugin)s") % {"name": pyfile.name, "plugin": pyfile.pluginname}) except Exception: @@ -139,7 +139,7 @@ class XMPPInterface(IRCInterface, JabberClient): to_name = to_jid.as_utf8() from_name = from_jid.as_utf8() - names = self.getConfig("owners").split(";") + names = self.getConfig('owners').split(";") if to_name in names or to_jid.node + "@" + to_jid.domain in names: messages = [] @@ -182,7 +182,7 @@ class XMPPInterface(IRCInterface, JabberClient): def announce(self, message): """ send message to all owners""" - for user in self.getConfig("owners").split(";"): + for user in self.getConfig('owners').split(";"): self.logDebug("Send message to", user) to_jid = JID(user) -- cgit v1.2.3 From 331045a39c1d52aef16d51fa4ae1f52ed4f8dc36 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 22:45:26 +0100 Subject: Tiny code cosmetics --- module/plugins/hooks/RestartFailed.py | 2 +- module/plugins/hooks/SkipRev.py | 6 +++--- module/plugins/hooks/UnSkipOnFail.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 7752b6a61..d0424bd1f 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -10,7 +10,7 @@ class RestartFailed(Hook): __config__ = [("interval", "int", "Check interval in minutes", 90)] - __description__ = """Periodically restart all failed downloads in queue""" + __description__ = """Restart all the failed downloads in queue""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 88ffb0103..dc45a2e6d 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -16,10 +16,10 @@ class SkipRev(Hook): __type__ = "hook" __version__ = "0.29" - __config__ = [("mode" , "Auto;Manual", "Choose rev files to skip for package", "Auto"), - ("revtokeep", "int" , "Number of rev files to keep" , 0 )] + __config__ = [("mode" , "Auto;Manual", "Choose recovery archives to skip" , "Auto"), + ("revtokeep", "int" , "Number of recovery archives to keep for package", 0 )] - __description__ = """Skip files ending with extension rev""" + __description__ = """Skip recovery archives (.rev)""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 7a5ae8e09..a2665663c 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -11,7 +11,7 @@ class UnSkipOnFail(Hook): __config__ = [("activated", "bool", "Activated", True)] - __description__ = """Queue skipped duplicates when download fails""" + __description__ = """Restart skipped duplicates when download fails""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From 864d3e2a1d6720f7db9c312a733d0fc0f906afb6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 13 Mar 2015 21:04:17 +0100 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1225 --- module/plugins/hooks/UpdateManager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 45d666f45..c435d38b2 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -28,7 +28,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.44" + __version__ = "0.45" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -205,7 +205,7 @@ class UpdateManager(Hook): # Protect UpdateManager from self-removing try: blacklisted.remove(("hook", "UpdateManager")) - except Exception: + except ValueError: pass for t, n in blacklisted: @@ -314,7 +314,7 @@ class UpdateManager(Hook): try: os.remove(filename) - except IOError, e: + except OSError, e: self.logError(_("Error removing: %s") % filename, e) else: -- cgit v1.2.3 From 0bce7503dda26b26a34549207eeab3b6bc4cb0dc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 14 Mar 2015 10:32:16 +0100 Subject: [HotFolder] Missing exception --- module/plugins/hooks/HotFolder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index a046e55e7..60ddf1621 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -14,7 +14,7 @@ from module.utils import fs_encode, save_join class HotFolder(Hook): __name__ = "HotFolder" __type__ = "hook" - __version__ = "0.13" + __version__ = "0.14" __config__ = [("folder" , "str" , "Folder to observe" , "container"), ("watch_file", "bool", "Observe link file" , False ), @@ -66,5 +66,5 @@ class HotFolder(Hook): self.logInfo(_("Added %s from HotFolder") % f) self.core.api.addPackage(f, [newpath], 1) - except IOError, e: + except (IOError, OSError), e: self.logError(e) -- cgit v1.2.3 From e65d19ee3a1e435bf2896ed829e5581eeef92dd2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 14 Mar 2015 11:07:54 +0100 Subject: Import cleanup for datetime and time modules --- module/plugins/hooks/Captcha9Kw.py | 10 +++++----- module/plugins/hooks/CaptchaBrotherhood.py | 4 ++-- module/plugins/hooks/DeathByCaptcha.py | 4 ++-- module/plugins/hooks/DownloadScheduler.py | 5 ++--- module/plugins/hooks/IRCInterface.py | 3 +-- module/plugins/hooks/MultiHome.py | 4 ++-- 6 files changed, 14 insertions(+), 16 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 6d42416ff..825db510b 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -3,9 +3,9 @@ from __future__ import with_statement import re +import time from base64 import b64encode -from time import sleep from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL @@ -134,7 +134,7 @@ class Captcha9Kw(Hook): try: res = getURL(self.API_URL, post=post_data) except BadHeader, e: - sleep(3) + time.sleep(3) else: if res and res.isdigit(): break @@ -156,7 +156,7 @@ class Captcha9Kw(Hook): 'action': "usercaptchacorrectdata"}) if not result or result == "NO DATA": - sleep(5) + time.sleep(5) else: break else: @@ -193,7 +193,7 @@ class Captcha9Kw(Hook): if queue < re.search(r'queue=(\d+)', servercheck).group(1): break - sleep(10) + time.sleep(10) else: self.fail(_("Too many captchas in queue")) @@ -244,7 +244,7 @@ class Captcha9Kw(Hook): if res == "OK": break - sleep(5) + time.sleep(5) else: self.logDebug("Could not send %s request: %s" % (type, res)) diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 5350b4f7d..161f2805b 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -4,13 +4,13 @@ from __future__ import with_statement import StringIO import pycurl +import time try: from PIL import Image except ImportError: import Image -from time import sleep from urllib import urlencode from module.network.RequestFactory import getURL, getRequest @@ -117,7 +117,7 @@ class CaptchaBrotherhood(Hook): ticket = res[3:] for _i in xrange(15): - sleep(5) + time.sleep(5) res = self.api_response("askCaptchaResult", ticket) if res.startswith("OK-answered"): return ticket, res[12:] diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 4eefb2bff..e408dcab7 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -3,10 +3,10 @@ from __future__ import with_statement import re +import time from base64 import b64encode from pycurl import FORM_FILE, HTTPHEADER -from time import sleep from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader @@ -152,7 +152,7 @@ class DeathByCaptcha(Hook): ticket = res['captcha'] for _i in xrange(24): - sleep(5) + time.sleep(5) res = self.api_response("captcha/%d" % ticket, False) if res['text'] and res['is_correct']: break diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 3b7ae524c..f24faa684 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from time import localtime +import time from module.plugins.Hook import Hook @@ -45,7 +44,7 @@ class DownloadScheduler(Hook): self.logError(_("Invalid schedule")) return - t0 = localtime() + t0 = time.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]) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 1c90c0e2f..7032c6592 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -8,7 +8,6 @@ import time from pycurl import FORM_FILE from select import select from threading import Thread -from time import sleep from traceback import print_exc from module.Api import PackageDoesNotExists, FileDoesNotExists @@ -116,7 +115,7 @@ class IRCInterface(Thread, Hook): def main_loop(self): readbuffer = "" while True: - sleep(1) + time.sleep(1) fdset = select([self.sock], [], [], 0) if self.sock not in fdset[0]: continue diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 9093c8459..7ea3378ec 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from time import time +import time from module.plugins.Hook import Hook @@ -80,7 +80,7 @@ class Interface(object): def useFor(self, pluginName, account): - self.history[(pluginName, account)] = time() + self.history[(pluginName, account)] = time.time() def __repr__(self): -- cgit v1.2.3 From d070742d8e4aebe59797a1ea86b51f9eb25915b4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 13:31:58 +0100 Subject: [AndroidPhoneNotify][WindowsPhoneNotify] New notifications --- module/plugins/hooks/AndroidPhoneNotify.py | 25 ++++++++++++++++++++++--- module/plugins/hooks/WindowsPhoneNotify.py | 25 ++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 180ad0d78..55ba3e73d 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -9,12 +9,14 @@ from module.plugins.Hook import Hook, Expose class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" __config__ = [("apikey" , "str" , "API key" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("notifyprocessed", "bool", "Notify packages processed" , True ), + ("notifyupdate" , "bool", "Notify plugin updates" , True ), + ("notifyexit" , "bool", "Notify pyLoad shutdown" , True ), ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), ("sendpermin" , "int" , "Max notifications per minute" , 12 ), ("ignoreclient" , "bool", "Send notifications if client is connected", False)] @@ -25,7 +27,7 @@ class AndroidPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - event_list = ["allDownloadsProcessed"] + event_list = ["allDownloadsProcessed", "plugin_updated"] #@TODO: Remove in 0.4.10 @@ -39,6 +41,23 @@ class AndroidPhoneNotify(Hook): self.notifications = 0 + def plugin_updated(self, type_plugins): + if not self.getConfig('notifyupdate'): + return + + self.notify(_("Plugins updated"), str(type_plugins)) + + + def coreExiting(self): + if not self.getConfig('notifyexit'): + return + + if self.core.do_restart: + self.notify(_("Restarting pyLoad")) + else: + self.notify(_("Exiting pyLoad")) + + def newCaptchaTask(self, task): if not self.getConfig('notifycaptcha'): return diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index a1068ead5..d8215f9fe 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -9,13 +9,15 @@ from module.plugins.Hook import Hook, Expose class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.08" + __version__ = "0.09" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("notifyprocessed", "bool", "Notify packages processed" , True ), + ("notifyupdate" , "bool", "Notify plugin updates" , True ), + ("notifyexit" , "bool", "Notify pyLoad shutdown" , True ), ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), ("sendpermin" , "int" , "Max notifications per minute" , 12 ), ("ignoreclient" , "bool", "Send notifications if client is connected", False)] @@ -26,7 +28,7 @@ class WindowsPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - event_list = ["allDownloadsProcessed"] + event_list = ["allDownloadsProcessed", "plugin_updated"] #@TODO: Remove in 0.4.10 @@ -40,6 +42,23 @@ class WindowsPhoneNotify(Hook): self.notifications = 0 + def plugin_updated(self, type_plugins): + if not self.getConfig('notifyupdate'): + return + + self.notify(_("Plugins updated"), str(type_plugins)) + + + def coreExiting(self): + if not self.getConfig('notifyexit'): + return + + if self.core.do_restart: + self.notify(_("Restarting pyLoad")) + else: + self.notify(_("Exiting pyLoad")) + + def newCaptchaTask(self, task): if not self.getConfig('notifycaptcha'): return -- cgit v1.2.3 From 80a5bc01bd854ba0ba80dccd7f1ca8f488be9112 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 13:34:09 +0100 Subject: [UpdateManager] Dispatch Event on plugins update --- module/plugins/hooks/UpdateManager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index c435d38b2..27d976f17 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -28,7 +28,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.45" + __version__ = "0.46" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -276,6 +276,8 @@ class UpdateManager(Hook): self.logInfo(_("*** Plugins have been updated, but need a pyLoad restart to be reloaded ***")) self.info['plugins'] = True exitcode = 2 + + self.manager.dispatchEvent("plugin_updated", updated) else: self.logInfo(_("No plugin updates available")) -- cgit v1.2.3 From 2bc144adb6bc2759b635e09687b27bf96074827f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 13:39:07 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/AntiVirus.py | 4 ++++ module/plugins/hooks/Checksum.py | 3 +++ module/plugins/hooks/ClickAndLoad.py | 4 ++++ module/plugins/hooks/DeleteFinished.py | 5 +++-- module/plugins/hooks/DownloadScheduler.py | 3 ++- module/plugins/hooks/HotFolder.py | 1 + module/plugins/hooks/JustPremium.py | 9 +++++++++ module/plugins/hooks/MergeFiles.py | 3 +-- module/plugins/hooks/MultiHome.py | 5 ++++- module/plugins/hooks/RestartFailed.py | 1 + module/plugins/hooks/SkipRev.py | 4 ++++ module/plugins/hooks/UnSkipOnFail.py | 3 +++ module/plugins/hooks/XFileSharingPro.py | 20 ++++++++++++-------- 13 files changed, 51 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index b8a659f99..ffed86836 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -30,6 +30,10 @@ class AntiVirus(Hook): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + @Expose @threaded def scan(self, pyfile, thread): diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 9474f6968..42a4ca236 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -75,9 +75,12 @@ class Checksum(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 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"] diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 731c8bd7e..812f969f9 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -41,6 +41,10 @@ class ClickAndLoad(Hook): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + def coreReady(self): if not self.config['webinterface']['activated']: return diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 5d2b78d50..e2ad12adb 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -44,7 +44,7 @@ class DeleteFinished(Hook): def coreReady(self): - self.info = {'sleep': True} + self.info['sleep'] = True interval = self.getConfig('interval') self.pluginConfigChanged(self.__name__, 'interval', interval) self.addEvent('packageFinished', self.wakeup) @@ -75,5 +75,6 @@ class DeleteFinished(Hook): def setup(self): - self.m = self.manager + self.info = {} #@TODO: Remove in 0.4.10 + self.m = self.manager self.removeEvent = self.m.removeEvent diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index f24faa684..5f9388b57 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -27,7 +27,8 @@ class DownloadScheduler(Hook): def setup(self): - self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded + self.info = {} #@TODO: Remove in 0.4.10 + self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded def coreReady(self): diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 60ddf1621..f771cf232 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -27,6 +27,7 @@ class HotFolder(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 self.interval = 30 diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 3064743e2..b82af3e78 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -23,6 +23,15 @@ class JustPremium(Hook): event_list = ["linksAdded"] + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + def linksAdded(self, links, pid): hosterdict = self.core.pluginManager.hosterPlugins linkdict = self.core.api.checkURLs(links) diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 9f1348485..74bcbe3c1 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -32,8 +32,7 @@ class MergeFiles(Hook): def setup(self): - # nothing to do - pass + self.info = {} #@TODO: Remove in 0.4.10 @threaded diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 7ea3378ec..94c671340 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -23,9 +23,12 @@ class MultiHome(Hook): def setup(self): - self.register = {} + self.info = {} #@TODO: Remove in 0.4.10 + self.register = {} self.interfaces = [] + self.parseInterfaces(self.getConfig('interfaces').split(";")) + if not self.interfaces: self.parseInterfaces([self.config['download']['interface']]) self.setConfig("interfaces", self.toConfig()) diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index d0424bd1f..6eef90ffe 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -37,6 +37,7 @@ class RestartFailed(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 self.interval = self.MIN_CHECK_INTERVAL diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index dc45a2e6d..9109d4f80 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -29,6 +29,10 @@ class SkipRev(Hook): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + @staticmethod def _setup(self): self.pyfile.plugin._setup() diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index a2665663c..f1f2288fe 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -20,6 +20,9 @@ class UnSkipOnFail(Hook): def initPeriodical(self): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + def downloadFailed(self, pyfile): #: Check if pyfile is still "failed", diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index d9552051e..69a49fba0 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.33" + __version__ = "0.34" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -22,11 +22,11 @@ class XFileSharingPro(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - # event_list = ["pluginConfigChanged"] - regexp = {'hoster' : (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', - r'https?://(?:[^/]+\.)?(?P%s)/(?:embed-)?\w+'), - 'crypter': (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', - r'https?://(?:[^/]+\.)?(?P%s)/(?:user|folder)s?/\w+')} + event_list = ["pluginConfigChanged"] + regexp = {'hoster' : (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', + r'https?://(?:[^/]+\.)?(?P%s)/(?:embed-)?\w+'), + 'crypter': (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', + r'https?://(?:[^/]+\.)?(?P%s)/(?:user|folder)s?/\w+')} HOSTER_BUILTIN = [#WORKING HOSTERS: "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", @@ -41,8 +41,8 @@ class XFileSharingPro(Hook): CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] - # def pluginConfigChanged(self.__name__, plugin, name, value): - # self.loadPattern() + def pluginConfigChanged(self.__name__, plugin, name, value): + self.loadPattern() #@TODO: Remove in 0.4.10 @@ -50,6 +50,10 @@ class XFileSharingPro(Hook): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + def coreReady(self): self.loadPattern() -- cgit v1.2.3 From a54c4268e402a3a1509c33d0b2de6f4336583416 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 15:39:11 +0100 Subject: [ExternalScripts] Fix https://github.com/pyload/pyload/issues/1233 --- module/plugins/hooks/ExternalScripts.py | 132 +++++++++++++++++++++----------- 1 file changed, 86 insertions(+), 46 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index d17e4740c..435ab618c 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.32" + __version__ = "0.35" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -23,8 +23,10 @@ class ExternalScripts(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - event_list = ["archive_extracted", "package_extracted", "all_archives_extracted", "all_archives_processed", - "allDownloadsFinished", "allDownloadsProcessed"] + event_list = ["archive_extract_failed", "archive_extracted" , + "package_extract_failed", "package_extracted" , + "all_archives_extracted", "all_archives_processed", + "allDownloadsFinished" , "allDownloadsProcessed" ] #@TODO: Remove in 0.4.10 @@ -33,14 +35,15 @@ class ExternalScripts(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 self.scripts = {} - folders = ["download_preparing", "download_finished", "all_downloads_finished", "all_downloads_processed", - "before_reconnect", "after_reconnect", - "package_finished", "package_extracted", - "archive_extracted", "all_archives_extracted", "all_archives_processed", - # deprecated folders - "unrar_finished", "all_dls_finished", "all_dls_processed"] + folders = ["before_reconnect", "after_reconnect", + "download_preparing", "download_failed", "download_finished", + "archive_extract_failed", "archive_extracted", + "package_finished", "package_extract_failed", "package_extracted", + "all_downloads_processed", "all_downloads_finished", #@TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10 + "all_archives_extracted", "all_archives_processed"] for folder in folders: self.scripts[folder] = [] @@ -49,7 +52,7 @@ class ExternalScripts(Hook): for script_type, names in self.scripts.iteritems(): if names: - self.logInfo(_("Installed scripts for ") + script_type, ", ".join(map(os.path.basename, names))) + self.logInfo(_("Installed scripts for: ") + script_type, ", ".join(map(os.path.basename, names))) def initPluginType(self, name, dir): @@ -57,12 +60,12 @@ class ExternalScripts(Hook): try: os.makedirs(dir) - except IOError, e: + except OSError, e: self.logDebug(e) return for filename in os.listdir(dir): - file = os.path.join(dir, filename) + file = save_join(dir, filename) if not os.path.isfile(file): continue @@ -78,76 +81,113 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] + cmd_args = [fs_encode(str(x) if not isinstance(x, basestring) else x) for x in args] + cmd = [script] + cmd_args - self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) + self.logDebug("Executing: %s" % os.path.abspath(script), "Args: " + ' '.join(cmd_args)) p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload if self.getConfig('waitend'): p.communicate() except Exception, e: - self.logError(_("Error in %(script)s: %(error)s") % {"script": os.path.basename(script), "error": e}) + try: + self.logError(_("Runtime error: %s") % os.path.abspath(script), e) + except Exception: + self.logError(_("Runtime error: %s") % os.path.abspath(script), _("Unknown error")) + + def beforeReconnecting(self, ip): + for script in self.scripts['before_reconnect']: + self.callScript(script, ip) + + + def afterReconnecting(self, ip): + for script in self.scripts['after_reconnect']: + self.callScript(script, ip) def downloadPreparing(self, pyfile): for script in self.scripts['download_preparing']: - self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.id) + self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, None) + + + def downloadFailed(self, pyfile): + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pyfile.package().folder) + else: + download_folder = self.config['general']['download_folder'] + + for script in self.scripts['download_failed']: + file = save_join(download_folder, pyfile.name) + self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file) def downloadFinished(self, pyfile): - download_folder = self.config['general']['download_folder'] + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pyfile.package().folder) + else: + download_folder = self.config['general']['download_folder'] + for script in self.scripts['download_finished']: - file = save_join(download_folder, pyfile.package().folder, pyfile.name) - self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, file, pyfile.id) + file = save_join(download_folder, pyfile.name) + self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file) - def packageFinished(self, pypack): - download_folder = self.config['general']['download_folder'] - for script in self.scripts['package_finished']: - folder = save_join(download_folder, pypack.folder) - self.callScript(script, pypack.name, folder, pypack.password, pypack.id) + def archive_extract_failed(self, pyfile, archive): + for script in self.scripts['archive_extract_failed']: + self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files) - def beforeReconnecting(self, ip): - for script in self.scripts['before_reconnect']: - self.callScript(script, ip) + def archive_extracted(self, pyfile, archive): + for script in self.scripts['archive_extracted']: + self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files) - def afterReconnecting(self, ip): - for script in self.scripts['after_reconnect']: - self.callScript(script, ip) + def packageFinished(self, pypack): + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pypack.folder) + else: + download_folder = self.config['general']['download_folder'] + for script in self.scripts['package_finished']: + self.callScript(script, pypack.id, pypack.name, download_folder) - def archive_extracted(self, pyfile, folder, filename, files): - for script in self.scripts['archive_extracted']: - self.callScript(script, folder, filename, files) - for script in self.scripts['unrar_finished']: #: deprecated - self.callScript(script, folder, filename) + + def package_extract_failed(self, pypack): + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pypack.folder) + else: + download_folder = self.config['general']['download_folder'] + + for script in self.scripts['package_extract_failed']: + self.callScript(script, pypack.id, pypack.name, download_folder) def package_extracted(self, pypack): - download_folder = self.config['general']['download_folder'] + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pypack.folder) + else: + download_folder = self.config['general']['download_folder'] + for script in self.scripts['package_extracted']: - folder = save_join(download_folder, pypack.folder) - self.callScript(script, pypack.name, folder, pypack.password, pypack.id) + self.callScript(script, pypack.id, pypack.name, download_folder) - def all_archives_extracted(self): - for script in self.scripts['all_archives_extracted']: + def allDownloadsFinished(self): + for script in self.scripts['all_downloads_finished']: self.callScript(script) - def all_archives_processed(self): - for script in self.scripts['all_archives_processed']: + def allDownloadsProcessed(self): + for script in self.scripts['all_downloads_processed']: self.callScript(script) - def allDownloadsFinished(self): - for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']: + def all_archives_extracted(self): + for script in self.scripts['all_archives_extracted']: self.callScript(script) - def allDownloadsProcessed(self): - for script in self.scripts['all_downloads_processed'] + self.scripts['all_dls_processed']: + def all_archives_processed(self): + for script in self.scripts['all_archives_processed']: self.callScript(script) -- cgit v1.2.3 From 93bfee64320aa39c06254975bc79f4796e6a7973 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 15:44:55 +0100 Subject: [XFileSharingPro] Fix typo --- module/plugins/hooks/XFileSharingPro.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 69a49fba0..54b1e27e6 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.34" + __version__ = "0.35" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -41,7 +41,7 @@ class XFileSharingPro(Hook): CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] - def pluginConfigChanged(self.__name__, plugin, name, value): + def pluginConfigChanged(self, plugin, name, value): self.loadPattern() -- cgit v1.2.3 From 753b3c9daee9926c84d4053864af2079fcfc8557 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 16:01:23 +0100 Subject: Spare code cosmetics (2) --- module/plugins/hooks/DeleteFinished.py | 8 ++++---- module/plugins/hooks/RestartFailed.py | 18 +++++++++--------- module/plugins/hooks/UpdateManager.py | 30 +++++++++++++++--------------- module/plugins/hooks/XFileSharingPro.py | 8 ++++---- 4 files changed, 32 insertions(+), 32 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index e2ad12adb..3dff9c7bd 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -33,10 +33,10 @@ class DeleteFinished(Hook): self.addEvent('packageFinished', self.wakeup) - def pluginConfigChanged(self, plugin, name, value): - if name == "interval" and value != self.interval: - self.interval = value * 3600 - self.initPeriodical() + # def pluginConfigChanged(self, plugin, name, value): + # if name == "interval" and value != self.interval: + # self.interval = value * 3600 + # self.initPeriodical() def unload(self): diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 6eef90ffe..c861e9c41 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -20,15 +20,15 @@ class RestartFailed(Hook): MIN_CHECK_INTERVAL = 15 * 60 #: 15 minutes - def pluginConfigChanged(self, plugin, name, value): - if name == "interval": - interval = value * 60 - if self.MIN_CHECK_INTERVAL <= interval != self.interval: - self.core.scheduler.removeJob(self.cb) - self.interval = interval - self.initPeriodical() - else: - self.logDebug("Invalid interval value, kept current") + # def pluginConfigChanged(self, plugin, name, value): + # if name == "interval": + # interval = value * 60 + # if self.MIN_CHECK_INTERVAL <= interval != self.interval: + # self.core.scheduler.removeJob(self.cb) + # self.interval = interval + # self.initPeriodical() + # else: + # self.logDebug("Invalid interval value, kept current") def periodical(self): diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 27d976f17..7270bc34f 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -49,21 +49,21 @@ class UpdateManager(Hook): MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours - def pluginConfigChanged(self, plugin, name, value): - if name == "interval": - interval = value * 60 * 60 - if self.MIN_CHECK_INTERVAL <= interval != self.interval: - 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.core.scheduler.removeJob(self.cb2) - if value is True and self.core.debug: - self.periodical2() + # def pluginConfigChanged(self, plugin, name, value): + # if name == "interval": + # interval = value * 60 * 60 + # if self.MIN_CHECK_INTERVAL <= interval != self.interval: + # 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.core.scheduler.removeJob(self.cb2) + # if value is True and self.core.debug: + # self.periodical2() def coreReady(self): diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 54b1e27e6..b7b5eed73 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.35" + __version__ = "0.36" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -22,7 +22,7 @@ class XFileSharingPro(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - event_list = ["pluginConfigChanged"] + # event_list = ["pluginConfigChanged"] regexp = {'hoster' : (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P%s)/(?:embed-)?\w+'), 'crypter': (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', @@ -41,8 +41,8 @@ class XFileSharingPro(Hook): CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] - def pluginConfigChanged(self, plugin, name, value): - self.loadPattern() + # def pluginConfigChanged(self, plugin, name, value): + # self.loadPattern() #@TODO: Remove in 0.4.10 -- cgit v1.2.3 From 990c1d9dd74b11b7110b2c66afb48704b5d5901f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 16:13:45 +0100 Subject: [ClickAndLoad] Fix freeze after a pyLoad restart --- module/plugins/hooks/ClickAndLoad.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 812f969f9..257f58584 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -24,7 +24,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.40" + __version__ = "0.41" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -58,6 +58,8 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): + time.sleep(10) #@TODO: Implement addon delay on start in 0.4.10 + self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) self._server(ip, webport, cnlport) -- cgit v1.2.3 From 6db62380b80a144aca18335d50c724e9915d8038 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 22:20:17 +0100 Subject: Hooks cleanup --- module/plugins/hooks/AlldebridCom.py | 2 -- module/plugins/hooks/DebridItaliaCom.py | 2 -- module/plugins/hooks/EasybytezCom.py | 2 -- module/plugins/hooks/FastixRu.py | 2 -- module/plugins/hooks/FreeWayMe.py | 2 -- module/plugins/hooks/LinksnappyCom.py | 2 -- module/plugins/hooks/MegaDebridEu.py | 2 -- module/plugins/hooks/MultishareCz.py | 2 -- module/plugins/hooks/MyfastfileCom.py | 2 -- module/plugins/hooks/NoPremiumPl.py | 2 -- module/plugins/hooks/OverLoadMe.py | 2 -- module/plugins/hooks/PremiumTo.py | 2 -- module/plugins/hooks/PremiumizeMe.py | 2 -- module/plugins/hooks/RPNetBiz.py | 2 -- module/plugins/hooks/RapideoPl.py | 2 -- module/plugins/hooks/RealdebridCom.py | 2 -- module/plugins/hooks/RehostTo.py | 2 -- module/plugins/hooks/SimplyPremiumCom.py | 2 -- module/plugins/hooks/SimplydebridCom.py | 2 -- module/plugins/hooks/SmoozedCom.py | 2 -- module/plugins/hooks/UnrestrictLi.py | 2 -- module/plugins/hooks/ZeveraCom.py | 2 -- 22 files changed, 44 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index 517adcb68..34f44c91d 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -11,8 +11,6 @@ class AlldebridCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 ), ("ssl" , "bool" , "Use HTTPS" , True )] diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py index 399f6462f..a970ae195 100644 --- a/module/plugins/hooks/DebridItaliaCom.py +++ b/module/plugins/hooks/DebridItaliaCom.py @@ -13,8 +13,6 @@ class DebridItaliaCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index 85c616054..04da21ee2 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -13,8 +13,6 @@ class EasybytezCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py index 6373da8d9..9e74587ac 100644 --- a/module/plugins/hooks/FastixRu.py +++ b/module/plugins/hooks/FastixRu.py @@ -12,8 +12,6 @@ class FastixRu(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index 4e79783bb..31ef8201f 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -11,8 +11,6 @@ class FreeWayMe(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/LinksnappyCom.py b/module/plugins/hooks/LinksnappyCom.py index 5eb0c7f6d..a5b77b93f 100644 --- a/module/plugins/hooks/LinksnappyCom.py +++ b/module/plugins/hooks/LinksnappyCom.py @@ -12,8 +12,6 @@ class LinksnappyCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/MegaDebridEu.py b/module/plugins/hooks/MegaDebridEu.py index f67fa7ac0..b32656019 100644 --- a/module/plugins/hooks/MegaDebridEu.py +++ b/module/plugins/hooks/MegaDebridEu.py @@ -12,8 +12,6 @@ class MegaDebridEu(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py index d02f4f8e3..e696d3fef 100644 --- a/module/plugins/hooks/MultishareCz.py +++ b/module/plugins/hooks/MultishareCz.py @@ -13,8 +13,6 @@ class MultishareCz(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/MyfastfileCom.py b/module/plugins/hooks/MyfastfileCom.py index 86408cb6d..1e7a6421d 100644 --- a/module/plugins/hooks/MyfastfileCom.py +++ b/module/plugins/hooks/MyfastfileCom.py @@ -12,8 +12,6 @@ class MyfastfileCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 1727bec70..77ee83cb1 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -12,8 +12,6 @@ class NoPremiumPl(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index 5e1040da7..7b9a1f414 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -11,8 +11,6 @@ class OverLoadMe(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 ), ("ssl" , "bool" , "Use HTTPS" , True )] diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index 250125016..f5636cb72 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -11,8 +11,6 @@ class PremiumTo(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py index 293fcf339..266c62549 100644 --- a/module/plugins/hooks/PremiumizeMe.py +++ b/module/plugins/hooks/PremiumizeMe.py @@ -12,8 +12,6 @@ class PremiumizeMe(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py index 0768bd6cd..a24697265 100644 --- a/module/plugins/hooks/RPNetBiz.py +++ b/module/plugins/hooks/RPNetBiz.py @@ -12,8 +12,6 @@ class RPNetBiz(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index b605eca17..70d499de5 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -12,8 +12,6 @@ class RapideoPl(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index c97bc257c..4260940d0 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -11,8 +11,6 @@ class RealdebridCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 ), ("ssl" , "bool" , "Use HTTPS" , True )] diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 845601c3f..1e608f87a 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -11,8 +11,6 @@ class RehostTo(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py index 843a3aa82..a5173dbfa 100644 --- a/module/plugins/hooks/SimplyPremiumCom.py +++ b/module/plugins/hooks/SimplyPremiumCom.py @@ -12,8 +12,6 @@ class SimplyPremiumCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py index 4d27f5ae4..a37a6eb7f 100644 --- a/module/plugins/hooks/SimplydebridCom.py +++ b/module/plugins/hooks/SimplydebridCom.py @@ -11,8 +11,6 @@ class SimplydebridCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/SmoozedCom.py b/module/plugins/hooks/SmoozedCom.py index 9ba2daac9..cd9b2fa6e 100644 --- a/module/plugins/hooks/SmoozedCom.py +++ b/module/plugins/hooks/SmoozedCom.py @@ -11,8 +11,6 @@ class SmoozedCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/UnrestrictLi.py b/module/plugins/hooks/UnrestrictLi.py index cb5abb26e..58f31f2aa 100644 --- a/module/plugins/hooks/UnrestrictLi.py +++ b/module/plugins/hooks/UnrestrictLi.py @@ -12,8 +12,6 @@ class UnrestrictLi(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 ), ("history" , "bool" , "Delete History" , False)] diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index 33c49d8be..7fcfb18da 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -11,8 +11,6 @@ class ZeveraCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] -- cgit v1.2.3 From 241d6fcca23656cf9690df455a0b7f9a44b472dd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 20 Mar 2015 01:37:20 +0100 Subject: [ExtractArchive] Update dispatchEvent --- module/plugins/hooks/ExternalScripts.py | 1 + module/plugins/hooks/ExtractArchive.py | 132 ++++++++++++++++---------------- 2 files changed, 68 insertions(+), 65 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 435ab618c..16049ae9b 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -96,6 +96,7 @@ class ExternalScripts(Hook): except Exception: self.logError(_("Runtime error: %s") % os.path.abspath(script), _("Unknown error")) + def beforeReconnecting(self, ip): for script in self.scripts['before_reconnect']: self.callScript(script, ip) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index edf25b8c7..0c163078c 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -12,8 +12,7 @@ from traceback import print_exc # 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": import errno - - from subprocess import Popen + import subprocess def _eintr_retry_call(func, *args): while True: @@ -44,13 +43,13 @@ if sys.version_info < (2, 7) and os.name != "nt": self._handle_exitstatus(sts) return self.returncode - Popen.wait = wait + subprocess.Popen.wait = wait if os.name != "nt": from grp import getgrnam from pwd import getpwnam -from module.plugins.Hook import Hook, threaded, Expose +from module.plugins.Hook import Hook, Expose, threaded from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError from module.plugins.internal.SimpleHoster import replace_patterns from module.utils import fs_encode, save_join, uniqify @@ -104,28 +103,27 @@ class ArchiveQueue(object): return self.set(queue) - class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.33" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (rar required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile", "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive when successfully extracted", False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Wait for all downloads to be finished" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __version__ = "1.34" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "bool" , "Delete archive after extraction" , False ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder", "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Run after all downloads was processed" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -139,6 +137,8 @@ class ExtractArchive(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + self.queue = ArchiveQueue(self, "Queue") self.failed = ArchiveQueue(self, "Failed") @@ -158,7 +158,7 @@ class ExtractArchive(Hook): if klass.isUsable(): self.extractors.append(klass) if klass.REPAIR: - self.repair = self.getConfig("repair") + self.repair = self.getConfig('repair') except OSError, e: if e.errno == 2: @@ -181,10 +181,10 @@ class ExtractArchive(Hook): @threaded - def extractQueued(self,thread): + def extractQueued(self, thread): packages = self.queue.get() while packages: - if self.lastPackage: # called from allDownloadsProcessed + if self.lastPackage: #: called from allDownloadsProcessed self.lastPackage = False if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") @@ -193,7 +193,7 @@ class ExtractArchive(Hook): if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now pass - packages = self.queue.get() # check for packages added during extraction + packages = self.queue.get() #: check for packages added during extraction @Expose @@ -201,7 +201,7 @@ class ExtractArchive(Hook): """ Extract packages with given id""" for id in ids: self.queue.add(id) - if not self.getConfig("waitall") and not self.extracting: + if not self.getConfig('waitall') and not self.extracting: self.extractQueued() @@ -211,7 +211,7 @@ class ExtractArchive(Hook): def packageFinished(self, pypack): self.queue.add(pypack.id) - if not self.getConfig("waitall") and not self.extracting: + if not self.getConfig('waitall') and not self.extracting: self.extractQueued() @@ -221,7 +221,8 @@ class ExtractArchive(Hook): self.extractQueued() - def extract(self, ids, thread=None): + @Expose + def extract(self, ids, thread=None): #@TODO: Use pypack, not pid to improve method usability if not ids: return False @@ -233,17 +234,17 @@ class ExtractArchive(Hook): toList = lambda string: string.replace(' ', '').replace(',', '|').replace(';', '|').split('|') - destination = self.getConfig("destination") - subfolder = self.getConfig("subfolder") - fullpath = self.getConfig("fullpath") - overwrite = self.getConfig("overwrite") - renice = self.getConfig("renice") - recursive = self.getConfig("recursive") - delete = self.getConfig("delete") - keepbroken = self.getConfig("keepbroken") + destination = self.getConfig('destination') + subfolder = self.getConfig('subfolder') + fullpath = self.getConfig('fullpath') + overwrite = self.getConfig('overwrite') + renice = self.getConfig('renice') + recursive = self.getConfig('recursive') + delete = self.getConfig('delete') + keepbroken = self.getConfig('keepbroken') - extensions = [x.lstrip('.').lower() for x in toList(self.getConfig("extensions"))] - excludefiles = toList(self.getConfig("excludefiles")) + extensions = [x.lstrip('.').lower() for x in toList(self.getConfig('extensions'))] + excludefiles = toList(self.getConfig('excludefiles')) if extensions: self.logDebug("Use for extensions: %s" % "|.".join(extensions)) @@ -254,7 +255,7 @@ class ExtractArchive(Hook): # dl folder dl = self.config['general']['download_folder'] - #iterate packages -> extractors -> targets + # iterate packages -> extractors -> targets for pid in ids: pypack = self.core.files.getPackage(pid) @@ -276,7 +277,7 @@ class ExtractArchive(Hook): matched = False success = True files_ids = dict((pylink['name'],((save_join(dl, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ - in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() # remove duplicates + in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates # check as long there are unseen files while files_ids: @@ -301,6 +302,7 @@ class ExtractArchive(Hook): self.logInfo(name, _("Extract to: %s") % fout) try: + pyfile = self.core.files.getFile(fid) archive = Extractor(self, fname, fout, @@ -311,16 +313,22 @@ class ExtractArchive(Hook): delete, keepbroken, fid) + + thread.addActive(pyfile) archive.init() - new_files = self._extract(archive, fid, pypack.password, thread) + try: + new_files = self._extract(pyfile, archive, pypack.password) + + finally: + thread.finishFile(pyfile) except Exception, e: self.logError(name, e) success = False continue - files_ids.remove((fname, fid, fout)) # don't let other extractors spam log + files_ids.remove((fname, fid, fout)) #: don't let other extractors spam log self.logDebug("Extracted files: %s" % new_files) self.setPermissions(new_files) @@ -331,12 +339,11 @@ class ExtractArchive(Hook): continue if recursive and os.path.isfile(file): - new_files_ids.append((filename, fid, os.path.dirname(filename))) # append as new target + new_files_ids.append((filename, fid, os.path.dirname(filename))) #: append as new target - pyfile = self.core.files.getFile(fid) - self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, new_files) + self.manager.dispatchEvent("archive_extracted", pyfile, archive) - files_ids = new_files_ids # also check extracted files + files_ids = new_files_ids #: also check extracted files if matched: if success: @@ -364,21 +371,19 @@ class ExtractArchive(Hook): return True if not failed else False - def _extract(self, archive, fid, password, thread): - pyfile = self.core.files.getFile(fid) + def _extract(self, pyfile, archive, password): name = os.path.basename(archive.filename) - thread.addActive(pyfile) pyfile.setStatus("processing") encrypted = False try: self.logDebug("Password: %s" % (password or "None provided")) - passwords = uniqify([password] + self.getPasswords(False)) if self.getConfig("usepasswordfile") else [password] + passwords = uniqify([password] + self.getPasswords(False)) if self.getConfig('usepasswordfile') else [password] for pw in passwords: try: - if self.getConfig("test") or self.repair: - pyfile.setCustomStatus(_("testing")) + if self.getConfig('test') or self.repair: + pyfile.setCustomStatus(_("archive testing")) if pw: self.logDebug("Testing with password: %s" % pw) pyfile.setProgress(0) @@ -402,12 +407,12 @@ class ExtractArchive(Hook): if self.repair: self.logWarning(name, _("Repairing...")) - pyfile.setCustomStatus(_("repairing")) + pyfile.setCustomStatus(_("archive repairing")) pyfile.setProgress(0) repaired = archive.repair() pyfile.setProgress(100) - if not repaired and not self.getConfig("keepbroken"): + if not repaired and not self.getConfig('keepbroken'): raise CRCError("Archive damaged") self.addPassword(pw) @@ -421,7 +426,7 @@ class ExtractArchive(Hook): pyfile.setCustomStatus(_("extracting")) pyfile.setProgress(0) - if not encrypted or not self.getConfig("usepasswordfile"): + if not encrypted or not self.getConfig('usepasswordfile'): self.logDebug("Extracting using password: %s" % (password or "None")) archive.extract(password) else: @@ -439,12 +444,12 @@ class ExtractArchive(Hook): raise PasswordError pyfile.setProgress(100) - pyfile.setCustomStatus(_("finalizing")) + pyfile.setStatus("processing") if self.core.debug: self.logDebug("Would delete: %s" % ", ".join(archive.getDeleteFiles())) - if self.getConfig("delete"): + if self.getConfig('delete'): files = archive.getDeleteFiles() self.logInfo(_("Deleting %s files") % len(files)) for f in files: @@ -473,10 +478,7 @@ class ExtractArchive(Hook): if self.core.debug: print_exc() - finally: - thread.finishFile(pyfile) - - self.manager.dispatchEvent("archive_extract_failed", pyfile) + self.manager.dispatchEvent("archive_extract_failed", pyfile, archive) raise Exception(_("Extract failed")) @@ -494,7 +496,7 @@ class ExtractArchive(Hook): try: passwords = [] - file = fs_encode(self.getConfig("passwordfile")) + file = fs_encode(self.getConfig('passwordfile')) with open(file) as f: for pw in f.read().splitlines(): passwords.append(pw) @@ -512,7 +514,7 @@ class ExtractArchive(Hook): try: self.passwords = uniqify([password] + self.passwords) - file = fs_encode(self.getConfig("passwordfile")) + file = fs_encode(self.getConfig('passwordfile')) with open(file, "wb") as f: for pw in self.passwords: f.write(pw + '\n') -- cgit v1.2.3 From 6fddff6b1c154ce1a34680bc22b6e39260f6a38c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 20 Mar 2015 03:16:32 +0100 Subject: [ExternalScripts] New events support --- module/plugins/hooks/ExternalScripts.py | 39 ++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 16049ae9b..dffa3649f 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.35" + __version__ = "0.36" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -26,7 +26,8 @@ class ExternalScripts(Hook): event_list = ["archive_extract_failed", "archive_extracted" , "package_extract_failed", "package_extracted" , "all_archives_extracted", "all_archives_processed", - "allDownloadsFinished" , "allDownloadsProcessed" ] + "allDownloadsFinished" , "allDownloadsProcessed" , + "packageDeleted"] #@TODO: Remove in 0.4.10 @@ -35,13 +36,14 @@ class ExternalScripts(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + self.info = {'oldip': None} self.scripts = {} - folders = ["before_reconnect", "after_reconnect", + folders = ["pyload_start", "pyload_restart", "pyload_shutdown", + "before_reconnect", "after_reconnect", "download_preparing", "download_failed", "download_finished", "archive_extract_failed", "archive_extracted", - "package_finished", "package_extract_failed", "package_extracted", + "package_finished", "package_deleted", "package_extract_failed", "package_extracted", "all_downloads_processed", "all_downloads_finished", #@TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10 "all_archives_extracted", "all_archives_processed"] @@ -54,6 +56,8 @@ class ExternalScripts(Hook): if names: self.logInfo(_("Installed scripts for: ") + script_type, ", ".join(map(os.path.basename, names))) + self.pyload_start() + def initPluginType(self, name, dir): if not os.path.isdir(dir): @@ -97,14 +101,25 @@ class ExternalScripts(Hook): self.logError(_("Runtime error: %s") % os.path.abspath(script), _("Unknown error")) + def pyload_start(self): + for script in self.scripts['pyload_start']: + self.callScript(script) + + + def coreExiting(self): + for script in self.scripts['pyload_restart' if self.core.do_restart else 'pyload_shutdown']: + self.callScript(script) + + def beforeReconnecting(self, ip): for script in self.scripts['before_reconnect']: self.callScript(script, ip) + self.info['oldip'] = ip def afterReconnecting(self, ip): for script in self.scripts['after_reconnect']: - self.callScript(script, ip) + self.callScript(script, ip, self.info['oldip']) #@TODO: Use built-in oldip in 0.4.10 def downloadPreparing(self, pyfile): @@ -154,6 +169,18 @@ class ExternalScripts(Hook): self.callScript(script, pypack.id, pypack.name, download_folder) + def packageDeleted(self, pid): + pack = self.core.api.getPackageInfo(pid) + + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pack.folder) + else: + download_folder = self.config['general']['download_folder'] + + for script in self.scripts['package_deleted']: + self.callScript(script, pack.id, pack.name, download_folder) + + def package_extract_failed(self, pypack): if self.config['general']['folder_per_package']: download_folder = save_join(self.config['general']['download_folder'], pypack.folder) -- cgit v1.2.3 From c4b30b08857225e6a70aa3171b6663d84e78b22f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 20 Mar 2015 11:22:16 +0100 Subject: [ExternalScripts] Rename pyload_shutdown to pyload_stop --- module/plugins/hooks/ExternalScripts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index dffa3649f..8f6c405fd 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.36" + __version__ = "0.37" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -39,7 +39,7 @@ class ExternalScripts(Hook): self.info = {'oldip': None} self.scripts = {} - folders = ["pyload_start", "pyload_restart", "pyload_shutdown", + folders = ["pyload_start", "pyload_restart", "pyload_stop", "before_reconnect", "after_reconnect", "download_preparing", "download_failed", "download_finished", "archive_extract_failed", "archive_extracted", @@ -107,7 +107,7 @@ class ExternalScripts(Hook): def coreExiting(self): - for script in self.scripts['pyload_restart' if self.core.do_restart else 'pyload_shutdown']: + for script in self.scripts['pyload_restart' if self.core.do_restart else 'pyload_stop']: self.callScript(script) -- cgit v1.2.3 From fb2d3d6b6a4b7be7fe0e771406e3acbf084d11f0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 21 Mar 2015 17:13:45 +0100 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1272 --- module/plugins/hooks/UpdateManager.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 7270bc34f..ca94548ea 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -28,7 +28,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.46" + __version__ = "0.47" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -44,26 +44,26 @@ class UpdateManager(Hook): # event_list = ["pluginConfigChanged"] - SERVER_URL = "http://updatemanager.pyload.org" - VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') + SERVER_URL = "http://updatemanager.pyload.org" + VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours - # def pluginConfigChanged(self, plugin, name, value): - # if name == "interval": - # interval = value * 60 * 60 - # if self.MIN_CHECK_INTERVAL <= interval != self.interval: + def pluginConfigChanged(self, plugin, name, value): + if name == "interval": + interval = value * 60 * 60 + if self.MIN_CHECK_INTERVAL <= interval != self.interval: # 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.core.scheduler.removeJob(self.cb2) - # if value is True and self.core.debug: - # self.periodical2() + 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) + if value is True and self.core.debug: + self.periodical2() def coreReady(self): -- cgit v1.2.3 From b9219fa1859de12de010a07c4c92a9f0270042ac Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 21 Mar 2015 17:17:03 +0100 Subject: [DeleteFinished] Define MIN_CHECK_INTERVAL --- module/plugins/hooks/DeleteFinished.py | 38 ++++++++++++++++++---------------- module/plugins/hooks/RestartFailed.py | 5 +++-- 2 files changed, 23 insertions(+), 20 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 3dff9c7bd..75cb33e96 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -7,11 +7,11 @@ from module.plugins.Hook import Hook class DeleteFinished(Hook): __name__ = "DeleteFinished" __type__ = "hook" - __version__ = "1.11" + __version__ = "1.12" - __config__ = [('activated', 'bool', 'Activated', 'False'), - ('interval', 'int', 'Delete every (hours)', '72'), - ('deloffline', 'bool', 'Delete packages with offline links', 'False')] + __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""" __license__ = "GPLv3" @@ -20,8 +20,15 @@ class DeleteFinished(Hook): # event_list = ["pluginConfigChanged"] + MIN_CHECK_INTERVAL = 1 * 60 * 60 #: 1 hour + ## overwritten methods ## + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + self.interval = self.MIN_CHECK_INTERVAL + + def periodical(self): if not self.info['sleep']: deloffline = self.getConfig('deloffline') @@ -40,13 +47,14 @@ class DeleteFinished(Hook): def unload(self): - self.removeEvent('packageFinished', self.wakeup) + self.manager.removeEvent('packageFinished', self.wakeup) def coreReady(self): self.info['sleep'] = True - interval = self.getConfig('interval') - self.pluginConfigChanged(self.__name__, 'interval', interval) + # interval = self.getConfig('interval') + # self.pluginConfigChanged(self.__name__, 'interval', interval) + self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60 * 60) self.addEvent('packageFinished', self.wakeup) @@ -58,23 +66,17 @@ class DeleteFinished(Hook): def wakeup(self, pypack): - self.removeEvent('packageFinished', self.wakeup) + self.manager.removeEvent('packageFinished', self.wakeup) self.info['sleep'] = False ## event managing ## def addEvent(self, event, func): """Adds an event listener for event name""" - if event in self.m.events: - if func in self.m.events[event]: + if event in self.manager.events: + if func in self.manager.events[event]: self.logDebug("Function already registered", func) else: - self.m.events[event].append(func) + self.manager.events[event].append(func) else: - self.m.events[event] = [func] - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.m = self.manager - self.removeEvent = self.m.removeEvent + self.manager.events[event] = [func] diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index c861e9c41..cab986d9e 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -6,7 +6,7 @@ from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" __type__ = "hook" - __version__ = "1.57" + __version__ = "1.58" __config__ = [("interval", "int", "Check interval in minutes", 90)] @@ -42,4 +42,5 @@ class RestartFailed(Hook): def coreReady(self): - self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) + # self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) + self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60) -- cgit v1.2.3 From 7bb9f21985abae3c15b6be9d6b7f7f8ba35405ba Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 22 Mar 2015 03:54:59 +0100 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1274 --- module/plugins/hooks/UpdateManager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index ca94548ea..7d8f44fef 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -28,7 +28,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.47" + __version__ = "0.48" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -136,6 +136,7 @@ class UpdateManager(Hook): @threaded def updateThread(self): + self.core.api.pauseServer() self.updating = True status = self.update(onlyplugin=self.getConfig('mode') == "plugins only") @@ -144,6 +145,7 @@ class UpdateManager(Hook): self.core.api.restart() else: self.updating = False + self.core.api.unpauseServer() @Expose -- cgit v1.2.3 From 25d7ae217d675d51110da5225e3d5c52202e8e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Sun, 22 Mar 2015 16:13:48 +0100 Subject: [AntiVirus] Typo & Remove Comment within Array --- module/plugins/hooks/AntiVirus.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index ffed86836..6f88b982a 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,9 +11,10 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" - __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), #@TODO: add trash option (use Send2Trash lib) + #@TODO: add trash option (use Send2Trash lib) + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), ("quardir" , "folder" , "Quarantine folder" , "" ), ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), ("cmdfile" , "file" , "Antivirus executable" , "" ), @@ -58,7 +59,7 @@ class AntiVirus(Hook): if err: self.logWarning(filename, err) - if not self.getConfig('ignore-err') + if not self.getConfig('ignore-err'): self.logDebug("Delete/Quarantine task is aborted") return -- cgit v1.2.3 From d0ef13775925f15811d2a6744d29190c313b3820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Mon, 23 Mar 2015 00:32:56 +0100 Subject: [ExtractArchive] extract archive even if first part is not in package --- module/plugins/hooks/ExtractArchive.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 0c163078c..d9af2dd49 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,7 +106,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.34" + __version__ = "1.35" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -328,7 +328,9 @@ class ExtractArchive(Hook): success = False continue - files_ids.remove((fname, fid, fout)) #: don't let other extractors spam log + # remove processed file and related multiparts from list + files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ + if fname not in archive.getDeleteFiles()] self.logDebug("Extracted files: %s" % new_files) self.setPermissions(new_files) -- cgit v1.2.3 From 61457a4e1b1ef95edbd7e7d82d01ad44d4158bdf Mon Sep 17 00:00:00 2001 From: Kagenoshin Date: Wed, 25 Mar 2015 10:51:46 +0100 Subject: New plugin: MegaRapidoNet --- module/plugins/hooks/MegaRapidoNet.py | 117 ++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 module/plugins/hooks/MegaRapidoNet.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/MegaRapidoNet.py b/module/plugins/hooks/MegaRapidoNet.py new file mode 100644 index 000000000..e59b94adf --- /dev/null +++ b/module/plugins/hooks/MegaRapidoNet.py @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- +import re + +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster + + +class MegaRapidoNet(MultiHoster): + __name__ = "MegaRapidoNet" + __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__ = """Megarapido.net 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 = { + '1fichier': [],#leave it there are so many possible addresses? + '1st-files': ['1st-files.com'], + '2shared': ['2shared.com'], + '4shared': ['4shared.com', '4shared-china.com'], + 'asfile': ['http://asfile.com/'], + 'bitshare': ['bitshare.com'], + 'brupload': ['brupload.net'], + 'crocko': ['crocko.com','easy-share.com'], + 'dailymotion': ['dailymotion.com'], + 'depfile': ['depfile.com'], + 'depositfiles': ['depositfiles.com', 'dfiles.eu'], + 'dizzcloud': ['dizzcloud.com'], + 'dl.dropbox': [], + 'extabit': ['extabit.com'], + 'extmatrix': ['extmatrix.com'], + 'facebook': [], + 'file4go': ['file4go.com'], + 'filecloud': ['filecloud.io','ifile.it','mihd.net'], + 'filefactory': ['filefactory.com'], + 'fileom': ['fileom.com'], + 'fileparadox': ['fileparadox.in'], + 'filepost': ['filepost.com', 'fp.io'], + 'filerio': ['filerio.in','filerio.com','filekeen.com'], + 'filesflash': ['filesflash.com'], + 'firedrive': ['firedrive.com', 'putlocker.com'], + 'flashx': [], + 'freakshare': ['freakshare.net', 'freakshare.com'], + 'gigasize': ['gigasize.com'], + 'hipfile': ['hipfile.com'], + 'junocloud': ['junocloud.me'], + 'letitbit': ['letitbit.net','shareflare.net'], + 'mediafire': ['mediafire.com'], + 'mega': ['mega.co.nz'], + 'megashares': ['megashares.com'], + 'metacafe': ['metacafe.com'], + 'netload': ['netload.in'], + 'oboom': ['oboom.com'], + 'rapidgator': ['rapidgator.net'], + 'rapidshare': ['rapidshare.com'], + 'rarefile': ['rarefile.net'], + 'ryushare': ['ryushare.com'], + 'sendspace': ['sendspace.com'], + 'turbobit': ['turbobit.net', 'unextfiles.com'], + 'uploadable': ['uploadable.ch'], + 'uploadbaz': ['uploadbaz.com'], + 'uploaded': ['uploaded.to', 'uploaded.net', 'ul.to'], + 'uploadhero': ['uploadhero.com'], + 'uploading': ['uploading.com'], + 'uptobox': ['uptobox.com'], + 'xvideos': ['xvideos.com'], + 'youtube': ['youtube.com'] + } + + #check if the list is still valid + #has to be added! 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 aaa8b74cbc8cab1ccd314c820b1fff5999bd2fd9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 25 Mar 2015 12:08:31 +0100 Subject: [MegaRapidoNet] Cleanup --- module/plugins/hooks/MegaRapidoNet.py | 178 ++++++++++++++-------------------- 1 file changed, 71 insertions(+), 107 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/MegaRapidoNet.py b/module/plugins/hooks/MegaRapidoNet.py index e59b94adf..33c74ae6f 100644 --- a/module/plugins/hooks/MegaRapidoNet.py +++ b/module/plugins/hooks/MegaRapidoNet.py @@ -1,117 +1,81 @@ # -*- coding: utf-8 -*- -import re - -from module.network.RequestFactory import getURL -from module.plugins.internal.MultiHoster import MultiHoster - - -class MegaRapidoNet(MultiHoster): - __name__ = "MegaRapidoNet" - __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__ = """Megarapido.net 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 = { - '1fichier': [],#leave it there are so many possible addresses? - '1st-files': ['1st-files.com'], - '2shared': ['2shared.com'], - '4shared': ['4shared.com', '4shared-china.com'], - 'asfile': ['http://asfile.com/'], - 'bitshare': ['bitshare.com'], - 'brupload': ['brupload.net'], - 'crocko': ['crocko.com','easy-share.com'], - 'dailymotion': ['dailymotion.com'], - 'depfile': ['depfile.com'], - 'depositfiles': ['depositfiles.com', 'dfiles.eu'], - 'dizzcloud': ['dizzcloud.com'], - 'dl.dropbox': [], - 'extabit': ['extabit.com'], - 'extmatrix': ['extmatrix.com'], - 'facebook': [], - 'file4go': ['file4go.com'], - 'filecloud': ['filecloud.io','ifile.it','mihd.net'], - 'filefactory': ['filefactory.com'], - 'fileom': ['fileom.com'], - 'fileparadox': ['fileparadox.in'], - 'filepost': ['filepost.com', 'fp.io'], - 'filerio': ['filerio.in','filerio.com','filekeen.com'], - 'filesflash': ['filesflash.com'], - 'firedrive': ['firedrive.com', 'putlocker.com'], - 'flashx': [], - 'freakshare': ['freakshare.net', 'freakshare.com'], - 'gigasize': ['gigasize.com'], - 'hipfile': ['hipfile.com'], - 'junocloud': ['junocloud.me'], - 'letitbit': ['letitbit.net','shareflare.net'], - 'mediafire': ['mediafire.com'], - 'mega': ['mega.co.nz'], - 'megashares': ['megashares.com'], - 'metacafe': ['metacafe.com'], - 'netload': ['netload.in'], - 'oboom': ['oboom.com'], - 'rapidgator': ['rapidgator.net'], - 'rapidshare': ['rapidshare.com'], - 'rarefile': ['rarefile.net'], - 'ryushare': ['ryushare.com'], - 'sendspace': ['sendspace.com'], - 'turbobit': ['turbobit.net', 'unextfiles.com'], - 'uploadable': ['uploadable.ch'], - 'uploadbaz': ['uploadbaz.com'], - 'uploaded': ['uploaded.to', 'uploaded.net', 'ul.to'], - 'uploadhero': ['uploadhero.com'], - 'uploading': ['uploading.com'], - 'uptobox': ['uptobox.com'], - 'xvideos': ['xvideos.com'], - 'youtube': ['youtube.com'] - } +import re - #check if the list is still valid - #has to be added! self.check_for_new_or_removed_hosters(hosters) +from module.plugins.internal.MultiHook import MultiHook + + +class MegaRapidoNet(MultiHook): + __name__ = "MegaRapidoNet" + __type__ = "hook" + __version__ = "0.02" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)", "" ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """MegaRapido.net hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] + + + def getHosters(self): + hosters = {'1fichier': [],#leave it there are so many possible addresses? + '1st-files': ['1st-files.com'], + '2shared': ['2shared.com'], + '4shared': ['4shared.com', '4shared-china.com'], + 'asfile': ['http://asfile.com/'], + 'bitshare': ['bitshare.com'], + 'brupload': ['brupload.net'], + 'crocko': ['crocko.com','easy-share.com'], + 'dailymotion': ['dailymotion.com'], + 'depfile': ['depfile.com'], + 'depositfiles': ['depositfiles.com', 'dfiles.eu'], + 'dizzcloud': ['dizzcloud.com'], + 'dl.dropbox': [], + 'extabit': ['extabit.com'], + 'extmatrix': ['extmatrix.com'], + 'facebook': [], + 'file4go': ['file4go.com'], + 'filecloud': ['filecloud.io','ifile.it','mihd.net'], + 'filefactory': ['filefactory.com'], + 'fileom': ['fileom.com'], + 'fileparadox': ['fileparadox.in'], + 'filepost': ['filepost.com', 'fp.io'], + 'filerio': ['filerio.in','filerio.com','filekeen.com'], + 'filesflash': ['filesflash.com'], + 'firedrive': ['firedrive.com', 'putlocker.com'], + 'flashx': [], + 'freakshare': ['freakshare.net', 'freakshare.com'], + 'gigasize': ['gigasize.com'], + 'hipfile': ['hipfile.com'], + 'junocloud': ['junocloud.me'], + 'letitbit': ['letitbit.net','shareflare.net'], + 'mediafire': ['mediafire.com'], + 'mega': ['mega.co.nz'], + 'megashares': ['megashares.com'], + 'metacafe': ['metacafe.com'], + 'netload': ['netload.in'], + 'oboom': ['oboom.com'], + 'rapidgator': ['rapidgator.net'], + 'rapidshare': ['rapidshare.com'], + 'rarefile': ['rarefile.net'], + 'ryushare': ['ryushare.com'], + 'sendspace': ['sendspace.com'], + 'turbobit': ['turbobit.net', 'unextfiles.com'], + 'uploadable': ['uploadable.ch'], + 'uploadbaz': ['uploadbaz.com'], + 'uploaded': ['uploaded.to', 'uploaded.net', 'ul.to'], + 'uploadhero': ['uploadhero.com'], + 'uploading': ['uploading.com'], + 'uptobox': ['uptobox.com'], + 'xvideos': ['xvideos.com'], + 'youtube': ['youtube.com']} - #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 ffb46ab200df55303836cc49e61b971b02e67ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Wed, 25 Mar 2015 18:39:54 +0100 Subject: [ExtractArchive] Send2Trash Integration --- module/plugins/hooks/ExtractArchive.py | 63 +++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 24 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index d9af2dd49..c0fe22545 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,24 +106,24 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.35" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile", "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive after extraction" , False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Run after all downloads was processed" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __version__ = "1.36" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "No;Permanent;Trash" , "Delete archive after extraction" , "No" ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder" , "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Run after all downloads was processed" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -148,6 +148,7 @@ class ExtractArchive(Hook): self.extractors = [] self.passwords = [] self.repair = False + self.trash = False def coreReady(self): @@ -448,15 +449,29 @@ class ExtractArchive(Hook): pyfile.setProgress(100) pyfile.setStatus("processing") + delfiles = archive.getDeleteFiles() if self.core.debug: - self.logDebug("Would delete: %s" % ", ".join(archive.getDeleteFiles())) + self.logDebug("Would delete: %s" % ", ".join(delfiles)) - if self.getConfig('delete'): - files = archive.getDeleteFiles() - self.logInfo(_("Deleting %s files") % len(files)) - for f in files: + if self.getConfig('delete') != 'No': + try: + from send2trash import send2trash + if self.getConfig('delete') == "Trash": + self.trash = True + self.logInfo(_("Sending %s files to trash") % len(delfiles)) + except ImportError: + self.logError(name, _("Send2Trash not installed, no files deleted")) + self.trash = False + + if self.getConfig('delete') == "Permanent": + self.trash = False + self.logInfo(_("Deleting %s files") % len(delfiles)) + + for f in delfiles: file = fs_encode(f) - if os.path.exists(file): + if os.path.exists(file) and self.trash: + send2trash(file) + elif os.path.exists: os.remove(file) else: self.logDebug("%s does not exists" % f) -- cgit v1.2.3 From f4f618f95a2348c8881ae455e1c8ad01ba3eae30 Mon Sep 17 00:00:00 2001 From: Gutz-Pilz Date: Wed, 25 Mar 2015 22:02:11 +0100 Subject: fixed "permanent" issue (forgot to change filversion) --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c0fe22545..5d71e89ec 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,7 +106,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.36" + __version__ = "1.37" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -471,7 +471,7 @@ class ExtractArchive(Hook): file = fs_encode(f) if os.path.exists(file) and self.trash: send2trash(file) - elif os.path.exists: + elif os.path.exists(file): os.remove(file) else: self.logDebug("%s does not exists" % f) -- cgit v1.2.3 From 7d90803262ccbb4fc5296a4dc3ce30fe98f55631 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 25 Mar 2015 23:10:07 +0100 Subject: __config__ cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/MegaRapidoNet.py | 100 +++++++++++++++++----------------- 2 files changed, 51 insertions(+), 51 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 257f58584..0564e31ca 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -58,7 +58,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - time.sleep(10) #@TODO: Implement addon delay on start in 0.4.10 + time.sleep(10) #@TODO: Remove in 0.4.10 (implement addon delay on startup) self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) diff --git a/module/plugins/hooks/MegaRapidoNet.py b/module/plugins/hooks/MegaRapidoNet.py index 33c74ae6f..fb5e77994 100644 --- a/module/plugins/hooks/MegaRapidoNet.py +++ b/module/plugins/hooks/MegaRapidoNet.py @@ -21,57 +21,57 @@ class MegaRapidoNet(MultiHook): def getHosters(self): - hosters = {'1fichier': [],#leave it there are so many possible addresses? - '1st-files': ['1st-files.com'], - '2shared': ['2shared.com'], - '4shared': ['4shared.com', '4shared-china.com'], - 'asfile': ['http://asfile.com/'], - 'bitshare': ['bitshare.com'], - 'brupload': ['brupload.net'], - 'crocko': ['crocko.com','easy-share.com'], - 'dailymotion': ['dailymotion.com'], - 'depfile': ['depfile.com'], + hosters = {'1fichier' : [],#leave it there are so many possible addresses? + '1st-files' : ['1st-files.com'], + '2shared' : ['2shared.com'], + '4shared' : ['4shared.com', '4shared-china.com'], + 'asfile' : ['http://asfile.com/'], + 'bitshare' : ['bitshare.com'], + 'brupload' : ['brupload.net'], + 'crocko' : ['crocko.com','easy-share.com'], + 'dailymotion' : ['dailymotion.com'], + 'depfile' : ['depfile.com'], 'depositfiles': ['depositfiles.com', 'dfiles.eu'], - 'dizzcloud': ['dizzcloud.com'], - 'dl.dropbox': [], - 'extabit': ['extabit.com'], - 'extmatrix': ['extmatrix.com'], - 'facebook': [], - 'file4go': ['file4go.com'], - 'filecloud': ['filecloud.io','ifile.it','mihd.net'], - 'filefactory': ['filefactory.com'], - 'fileom': ['fileom.com'], - 'fileparadox': ['fileparadox.in'], - 'filepost': ['filepost.com', 'fp.io'], - 'filerio': ['filerio.in','filerio.com','filekeen.com'], - 'filesflash': ['filesflash.com'], - 'firedrive': ['firedrive.com', 'putlocker.com'], - 'flashx': [], - 'freakshare': ['freakshare.net', 'freakshare.com'], - 'gigasize': ['gigasize.com'], - 'hipfile': ['hipfile.com'], - 'junocloud': ['junocloud.me'], - 'letitbit': ['letitbit.net','shareflare.net'], - 'mediafire': ['mediafire.com'], - 'mega': ['mega.co.nz'], - 'megashares': ['megashares.com'], - 'metacafe': ['metacafe.com'], - 'netload': ['netload.in'], - 'oboom': ['oboom.com'], - 'rapidgator': ['rapidgator.net'], - 'rapidshare': ['rapidshare.com'], - 'rarefile': ['rarefile.net'], - 'ryushare': ['ryushare.com'], - 'sendspace': ['sendspace.com'], - 'turbobit': ['turbobit.net', 'unextfiles.com'], - 'uploadable': ['uploadable.ch'], - 'uploadbaz': ['uploadbaz.com'], - 'uploaded': ['uploaded.to', 'uploaded.net', 'ul.to'], - 'uploadhero': ['uploadhero.com'], - 'uploading': ['uploading.com'], - 'uptobox': ['uptobox.com'], - 'xvideos': ['xvideos.com'], - 'youtube': ['youtube.com']} + 'dizzcloud' : ['dizzcloud.com'], + 'dl.dropbox' : [], + 'extabit' : ['extabit.com'], + 'extmatrix' : ['extmatrix.com'], + 'facebook' : [], + 'file4go' : ['file4go.com'], + 'filecloud' : ['filecloud.io','ifile.it','mihd.net'], + 'filefactory' : ['filefactory.com'], + 'fileom' : ['fileom.com'], + 'fileparadox' : ['fileparadox.in'], + 'filepost' : ['filepost.com', 'fp.io'], + 'filerio' : ['filerio.in','filerio.com','filekeen.com'], + 'filesflash' : ['filesflash.com'], + 'firedrive' : ['firedrive.com', 'putlocker.com'], + 'flashx' : [], + 'freakshare' : ['freakshare.net', 'freakshare.com'], + 'gigasize' : ['gigasize.com'], + 'hipfile' : ['hipfile.com'], + 'junocloud' : ['junocloud.me'], + 'letitbit' : ['letitbit.net','shareflare.net'], + 'mediafire' : ['mediafire.com'], + 'mega' : ['mega.co.nz'], + 'megashares' : ['megashares.com'], + 'metacafe' : ['metacafe.com'], + 'netload' : ['netload.in'], + 'oboom' : ['oboom.com'], + 'rapidgator' : ['rapidgator.net'], + 'rapidshare' : ['rapidshare.com'], + 'rarefile' : ['rarefile.net'], + 'ryushare' : ['ryushare.com'], + 'sendspace' : ['sendspace.com'], + 'turbobit' : ['turbobit.net', 'unextfiles.com'], + 'uploadable' : ['uploadable.ch'], + 'uploadbaz' : ['uploadbaz.com'], + 'uploaded' : ['uploaded.to', 'uploaded.net', 'ul.to'], + 'uploadhero' : ['uploadhero.com'], + 'uploading' : ['uploading.com'], + 'uptobox' : ['uptobox.com'], + 'xvideos' : ['xvideos.com'], + 'youtube' : ['youtube.com']} hoster_list = [] -- cgit v1.2.3 From b6dc723bf214e8680f7be29594581d3da5033b90 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 26 Mar 2015 09:57:34 +0100 Subject: [UpdateManager] Update --- module/plugins/hooks/UpdateManager.py | 173 ++++++++++++++++------------------ 1 file changed, 80 insertions(+), 93 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 7d8f44fef..643b5c2d1 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -5,6 +5,7 @@ from __future__ import with_statement import os import re import sys +import time from operator import itemgetter @@ -28,67 +29,57 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.48" + __version__ = "0.50" - __config__ = [("activated" , "bool" , "Activated" , True ), - ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), - ("interval" , "int" , "Check interval in hours" , 8 ), - ("autorestart" , "bool" , "Automatically restart pyLoad when required" , True ), - ("reloadplugins", "bool" , "Monitor plugins for code changes in debug mode", True ), - ("nodebugupdate", "bool" , "Don't check for updates in debug mode" , False )] + __config__ = [("activated" , "bool", "Activated" , True ), + ("checkinterval", "int" , "Check interval in hours" , 8 ), + ("autorestart" , "bool", "Auto-restart pyLoad when required" , True ), + ("checkonstart" , "bool", "Check for updates on startup" , True ), + ("checkperiod" , "bool", "Check for updates periodically" , True ), + ("reloadplugins", "bool", "Monitor plugin code changes in debug mode", True ), + ("nodebugupdate", "bool", "Don't update plugins in debug mode" , False)] __description__ = """ Check for updates """ __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - # event_list = ["pluginConfigChanged"] + interval = 0 SERVER_URL = "http://updatemanager.pyload.org" - VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours - def pluginConfigChanged(self, plugin, name, value): - if name == "interval": - interval = value * 60 * 60 - if self.MIN_CHECK_INTERVAL <= interval != self.interval: - # 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.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')) - x = lambda: self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig('reloadplugins')) - self.core.scheduler.addJob(10, x, threaded=False) + if self.checkonstart: + self.update() - - def unload(self): - self.pluginConfigChanged(self.__name__, "reloadplugins", False) + self.initPeriodical() def setup(self): - self.cb2 = None - self.interval = self.MIN_CHECK_INTERVAL - self.updating = False - self.info = {'pyload': False, 'version': None, 'plugins': False} + self.interval = 10 + self.info = {'pyload': False, 'version': None, 'plugins': False, 'last_check': time.time()} self.mtimes = {} #: store modification time for each plugin + if self.getConfig('checkonstart'): + self.core.api.pauseServer() + self.checkonstart = True + else: + self.checkonstart = False - def periodical2(self): - if not self.updating: - self.autoreloadPlugins() - self.cb2 = self.core.scheduler.addJob(4, self.periodical2, threaded=False) + def periodical(self): + if self.core.debug: + if self.getConfig('reloadplugins'): + self.autoreloadPlugins() + + if self.getConfig('nodebugupdate'): + return + + if self.getConfig('checkperiod') \ + and time.time() - max(self.MIN_CHECK_INTERVAL, self.getConfig('checkinterval') * 60 * 60) > self.info['last_check']: + self.update() @Expose @@ -121,11 +112,6 @@ 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): - self.updateThread() - - def server_response(self): try: return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() @@ -134,95 +120,92 @@ class UpdateManager(Hook): self.logWarning(_("Unable to contact server to get updates")) + @Expose @threaded - def updateThread(self): - self.core.api.pauseServer() - self.updating = True + def update(self): + """ check for updates """ - status = self.update(onlyplugin=self.getConfig('mode') == "plugins only") + self.core.api.pauseServer() - if status is 2 and self.getConfig('autorestart'): + if self._update() is 2 and self.getConfig('autorestart'): self.core.api.restart() else: - self.updating = False self.core.api.unpauseServer() - @Expose - def updatePlugins(self): - """ simple wrapper for calling plugin update quickly """ - return self.update(onlyplugin=True) - - - @Expose - def update(self, onlyplugin=False): - """ check for updates """ + def _update(self): data = self.server_response() + self.info['last_check'] = time.time() + if not data: exitcode = 0 elif data[0] == "None": self.logInfo(_("No new pyLoad version available")) - updates = data[1:] - exitcode = self._updatePlugins(updates) + exitcode = self._updatePlugins(data[1:]) elif onlyplugin: exitcode = 0 else: - newversion = data[0] - self.logInfo(_("*** New pyLoad Version %s available ***") % newversion) + self.logInfo(_("*** New pyLoad Version %s available ***") % data[0]) self.logInfo(_("*** Get it here: https://github.com/pyload/pyload/releases ***")) + self.info['pyload'] = True + self.info['version'] = data[0] exitcode = 3 - self.info['pyload'] = True - self.info['version'] = newversion - return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required; 3 = No plugins updated, new pyLoad version available + # Exit codes: + # -1 = No plugin updated, new pyLoad version available + # 0 = No plugin updated + # 1 = Plugins updated + # 2 = Plugins updated, but restart required + return exitcode - def _updatePlugins(self, updates): + def _updatePlugins(self, data): """ check for plugin updates """ - if self.info['plugins']: - return False #: plugins were already updated - exitcode = 0 updated = [] - url = updates[0] - schema = updates[1].split('|') + url = data[0] + schema = data[1].split('|') - if "BLACKLIST" in updates: - blacklist = updates[updates.index('BLACKLIST') + 1:] - updates = updates[2:updates.index('BLACKLIST')] + VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') + + if "BLACKLIST" in data: + blacklist = data[data.index('BLACKLIST') + 1:] + updatelist = data[2:data.index('BLACKLIST')] else: - blacklist = None - updates = updates[2:] + blacklist = [] + updatelist = data[2:] - upgradable = [dict(zip(schema, x.split('|'))) for x in updates] - blacklisted = [(x.split('|')[0], x.split('|')[1].rsplit('.', 1)[0]) for x in blacklist] if blacklist else [] + updatelist = [dict(zip(schema, x.split('|'))) for x in updatelist] + blacklist = [dict(zip(schema, x.split('|'))) for x in blacklist] if blacklist: + type_plugins = [(plugin['type'], plugin['name'].rsplit('.', 1)[0]) for plugin in blacklist] + # Protect UpdateManager from self-removing try: - blacklisted.remove(("hook", "UpdateManager")) + type_plugins.remove(("hook", "UpdateManager")) except ValueError: pass - for t, n in blacklisted: - for idx, plugin in enumerate(upgradable): + for t, n in type_plugins: + for idx, plugin in enumerate(updatelist): if n == plugin['name'] and t == plugin['type']: - upgradable.pop(idx) + updatelist.pop(idx) break - for t, n in self.removePlugins(sorted(blacklisted)): + for t, n in self.removePlugins(sorted(type_plugins)): self.logInfo(_("Removed blacklisted plugin: [%(type)s] %(name)s") % { 'type': t, 'name': n, }) - for plugin in sorted(upgradable, key=itemgetter("type", "name")): + for plugin in sorted(updatelist, key=itemgetter("type", "name")): filename = plugin['name'] prefix = plugin['type'] version = plugin['version'] @@ -256,7 +239,7 @@ class UpdateManager(Hook): 'newver': newver}) try: content = getURL(url % plugin) - m = self.VERSION.search(content) + m = VERSION.search(content) if m and m.group(2) == version: with open(save_join("userplugins", prefix, filename), "wb") as f: @@ -267,15 +250,15 @@ class UpdateManager(Hook): raise Exception, _("Version mismatch") except Exception, e: - self.logError(_("Error updating plugin: %s") % filename, str(e)) + self.logError(_("Error updating plugin: %s") % filename, e) if updated: - reloaded = self.core.pluginManager.reloadPlugins(updated) - if reloaded: - self.logInfo(_("Plugins updated and reloaded")) + self.logInfo(_("*** Plugins updated ***")) + + if self.core.pluginManager.reloadPlugins(updated): exitcode = 1 else: - self.logInfo(_("*** Plugins have been updated, but need a pyLoad restart to be reloaded ***")) + self.logWarning(_("pyLoad restart required to reload the updated plugins")) self.info['plugins'] = True exitcode = 2 @@ -283,7 +266,11 @@ class UpdateManager(Hook): else: self.logInfo(_("No plugin updates available")) - return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required + # Exit codes: + # 0 = No plugin updated + # 1 = Plugins updated + # 2 = Plugins updated, but restart required + return exitcode @Expose -- cgit v1.2.3 From f1ce338ed31e49373cea5453a2fbdb6c686ca510 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 26 Mar 2015 10:16:04 +0100 Subject: interval code cosmetics --- module/plugins/hooks/AndroidPhoneNotify.py | 6 +----- module/plugins/hooks/AntiVirus.py | 4 +--- module/plugins/hooks/BypassCaptcha.py | 7 ++----- module/plugins/hooks/Captcha9Kw.py | 7 ++----- module/plugins/hooks/CaptchaBrotherhood.py | 7 ++----- module/plugins/hooks/Checksum.py | 20 ++++++++------------ module/plugins/hooks/ClickAndLoad.py | 4 +--- module/plugins/hooks/DeathByCaptcha.py | 7 ++----- module/plugins/hooks/DownloadScheduler.py | 4 +--- module/plugins/hooks/ExpertDecoders.py | 7 ++----- module/plugins/hooks/ExternalScripts.py | 6 +----- module/plugins/hooks/IRCInterface.py | 8 +++----- module/plugins/hooks/ImageTyperz.py | 7 ++----- module/plugins/hooks/JustPremium.py | 6 +----- module/plugins/hooks/MergeFiles.py | 7 ++----- module/plugins/hooks/MultiHome.py | 4 +--- module/plugins/hooks/RestartSlow.py | 5 +---- module/plugins/hooks/SkipRev.py | 4 +--- module/plugins/hooks/UnSkipOnFail.py | 5 ++--- module/plugins/hooks/WindowsPhoneNotify.py | 6 +----- module/plugins/hooks/XFileSharingPro.py | 6 +----- 21 files changed, 38 insertions(+), 99 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 55ba3e73d..67a0ea4f0 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -28,11 +28,7 @@ class AndroidPhoneNotify(Hook): event_list = ["allDownloadsProcessed", "plugin_updated"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 6f88b982a..cc3c5c754 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -26,9 +26,7 @@ class AntiVirus(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index d7995650b..3c8f72524 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -40,6 +40,8 @@ class BypassCaptcha(Hook): ("zoidberg" , "zoidberg@mujmail.cz" )] + interval = 0 #@TODO: Remove in 0.4.10 + PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32" SUBMIT_URL = "http://bypasscaptcha.com/upload.php" @@ -47,11 +49,6 @@ class BypassCaptcha(Hook): GETCREDITS_URL = "http://bypasscaptcha.com/ex_left.php" - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def setup(self): self.info = {} #@TODO: Remove in 0.4.10 diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 825db510b..60482b8fc 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -36,12 +36,9 @@ class Captcha9Kw(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - API_URL = "http://www.9kw.eu/index.cgi" - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + API_URL = "http://www.9kw.eu/index.cgi" def setup(self): diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 161f2805b..e5285a493 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -50,12 +50,9 @@ class CaptchaBrotherhood(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - API_URL = "http://www.captchabrotherhood.com/" - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + API_URL = "http://www.captchabrotherhood.com/" def setup(self): diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 42a4ca236..4ad17f55a 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -55,18 +55,14 @@ class Checksum(Hook): ("stickell" , "l.stickell@yahoo.it")] - methods = {'sfv' : 'crc32', - 'crc' : 'crc32', - 'hash': 'md5'} - regexps = {'sfv' : r'^(?P[^;].+)\s+(?P[0-9A-Fa-f]{8})$', - 'md5' : r'^(?P[0-9A-Fa-f]{32}) (?P.+)$', - 'crc' : r'filename=(?P.+)\nsize=(?P\d+)\ncrc32=(?P[0-9A-Fa-f]{8})$', - 'default': r'^(?P[0-9A-Fa-f]+)\s+\*?(?P.+)$'} - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 + methods = {'sfv' : 'crc32', + 'crc' : 'crc32', + 'hash': 'md5'} + regexps = {'sfv' : r'^(?P[^;].+)\s+(?P[0-9A-Fa-f]{8})$', + 'md5' : r'^(?P[0-9A-Fa-f]{32}) (?P.+)$', + '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): diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 0564e31ca..2ddd66daa 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -36,9 +36,7 @@ class ClickAndLoad(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index e408dcab7..501de0c1a 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -63,12 +63,9 @@ class DeathByCaptcha(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - API_URL = "http://api.dbcapi.me/api/" - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + API_URL = "http://api.dbcapi.me/api/" def setup(self): diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 5f9388b57..9c74ac1d4 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -21,9 +21,7 @@ class DownloadScheduler(Hook): ("stickell", "l.stickell@yahoo.it")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index fa1c7a14b..79e98c020 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -25,12 +25,9 @@ class ExpertDecoders(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - API_URL = "http://www.fasttypers.org/imagepost.ashx" - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + API_URL = "http://www.fasttypers.org/imagepost.ashx" def setup(self): diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 8f6c405fd..8ab7af55c 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -28,11 +28,7 @@ class ExternalScripts(Hook): "all_archives_extracted", "all_archives_processed", "allDownloadsFinished" , "allDownloadsProcessed" , "packageDeleted"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 7032c6592..d76b9cb85 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -37,17 +37,15 @@ class IRCInterface(Thread, Hook): __authors__ = [("Jeix", "Jeix@hasnomail.com")] + interval = 0 #@TODO: Remove in 0.4.10 + + def __init__(self, core, manager): Thread.__init__(self) Hook.__init__(self, core, manager) self.setDaemon(True) - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def coreReady(self): self.abort = False self.more = [] diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 2cf611b9f..132ab2e02 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -44,16 +44,13 @@ class ImageTyperz(Hook): ("zoidberg", "zoidberg@mujmail.cz")] + interval = 0 #@TODO: Remove in 0.4.10 + SUBMIT_URL = "http://captchatypers.com/Forms/UploadFileAndGetTextNEW.ashx" RESPOND_URL = "http://captchatypers.com/Forms/SetBadImage.ashx" GETCREDITS_URL = "http://captchatypers.com/Forms/RequestBalance.ashx" - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def setup(self): self.info = {} #@TODO: Remove in 0.4.10 diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index b82af3e78..d18afc524 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -21,11 +21,7 @@ class JustPremium(Hook): event_list = ["linksAdded"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 74bcbe3c1..2900b0d29 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -23,12 +23,9 @@ class MergeFiles(Hook): __authors__ = [("and9000", "me@has-no-mail.com")] - BUFFER_SIZE = 4096 - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + BUFFER_SIZE = 4096 def setup(self): diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 94c671340..a26d139c0 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -17,9 +17,7 @@ class MultiHome(Hook): __authors__ = [("mkaay", "mkaay@mkaay.de")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/RestartSlow.py b/module/plugins/hooks/RestartSlow.py index 834128489..db535b3d1 100644 --- a/module/plugins/hooks/RestartSlow.py +++ b/module/plugins/hooks/RestartSlow.py @@ -22,16 +22,13 @@ class RestartSlow(Hook): event_list = ["downloadStarts"] + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): self.info = {'chunk': {}} - def initPeriodical(self): - pass - - def periodical(self): if not self.pyfile.plugin.req.dl: return diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 9109d4f80..157b55bbd 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -24,9 +24,7 @@ class SkipRev(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index f1f2288fe..ebd370a0f 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -16,9 +16,8 @@ class UnSkipOnFail(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 + def setup(self): self.info = {} #@TODO: Remove in 0.4.10 diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index d8215f9fe..e61057f9f 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -29,11 +29,7 @@ class WindowsPhoneNotify(Hook): event_list = ["allDownloadsProcessed", "plugin_updated"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index b7b5eed73..4f8b0a846 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -23,6 +23,7 @@ class XFileSharingPro(Hook): # event_list = ["pluginConfigChanged"] + interval = 0 #@TODO: Remove in 0.4.10 regexp = {'hoster' : (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P%s)/(?:embed-)?\w+'), 'crypter': (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', @@ -45,11 +46,6 @@ class XFileSharingPro(Hook): # self.loadPattern() - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def setup(self): self.info = {} #@TODO: Remove in 0.4.10 -- cgit v1.2.3 From 329293e0bb0cf4008688d8c73d4b98caa7082141 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 26 Mar 2015 10:40:32 +0100 Subject: [Extractor] Rename method 'test' to 'verify' --- module/plugins/hooks/ExtractArchive.py | 61 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 5d71e89ec..c5f842fdd 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,24 +106,24 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.37" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile", "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "No;Permanent;Trash" , "Delete archive after extraction" , "No" ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder" , "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Run after all downloads was processed" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __version__ = "1.38" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "No;Permanent;Trash", "Delete archive after extraction" , "No" ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder" , "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Run after all downloads was processed" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -235,14 +235,14 @@ class ExtractArchive(Hook): toList = lambda string: string.replace(' ', '').replace(',', '|').replace(';', '|').split('|') - destination = self.getConfig('destination') - subfolder = self.getConfig('subfolder') - fullpath = self.getConfig('fullpath') - overwrite = self.getConfig('overwrite') - renice = self.getConfig('renice') - recursive = self.getConfig('recursive') - delete = self.getConfig('delete') - keepbroken = self.getConfig('keepbroken') + destination = self.getConfig('destination') + subfolder = self.getConfig('subfolder') + fullpath = self.getConfig('fullpath') + overwrite = self.getConfig('overwrite') + renice = self.getConfig('renice') + recursive = self.getConfig('recursive') + delete = self.getConfig('delete') + keepbroken = self.getConfig('keepbroken') extensions = [x.lstrip('.').lower() for x in toList(self.getConfig('extensions'))] excludefiles = toList(self.getConfig('excludefiles')) @@ -253,8 +253,7 @@ class ExtractArchive(Hook): # reload from txt file self.reloadPasswords() - # dl folder - dl = self.config['general']['download_folder'] + download_folder = self.config['general']['download_folder'] # iterate packages -> extractors -> targets for pid in ids: @@ -267,7 +266,7 @@ class ExtractArchive(Hook): self.logInfo(_("Check package: %s") % pypack.name) # determine output folder - out = save_join(dl, pypack.folder, destination, "") #: force trailing slash + out = save_join(download_folder, pypack.folder, destination, "") #: force trailing slash if subfolder: out = save_join(out, pypack.folder) @@ -277,7 +276,7 @@ class ExtractArchive(Hook): matched = False success = True - files_ids = dict((pylink['name'],((save_join(dl, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ + files_ids = dict((pylink['name'],((save_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates # check as long there are unseen files @@ -390,7 +389,7 @@ class ExtractArchive(Hook): if pw: self.logDebug("Testing with password: %s" % pw) pyfile.setProgress(0) - archive.test(pw) + archive.verify(pw) pyfile.setProgress(100) else: archive.check(pw) -- cgit v1.2.3