From cf6531b2c87fea99fd03884636bac4c80d1b475d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 4 Oct 2015 20:09:55 +0200 Subject: Fixpack (3) --- module/plugins/accounts/FreakshareCom.py | 2 +- module/plugins/accounts/HellshareCz.py | 2 +- module/plugins/accounts/OneFichierCom.py | 2 +- module/plugins/captcha/AdYouLike.py | 2 +- module/plugins/captcha/AdsCaptcha.py | 4 +- module/plugins/captcha/ReCaptcha.py | 4 +- module/plugins/captcha/SolveMedia.py | 2 +- module/plugins/crypter/Dereferer.py | 2 +- module/plugins/crypter/FilecryptCc.py | 2 +- module/plugins/crypter/ILoadTo.py | 2 +- module/plugins/crypter/SafelinkingNet.py | 2 +- module/plugins/crypter/SecuredIn.py | 2 +- module/plugins/crypter/ShareLinksBiz.py | 2 +- module/plugins/crypter/TinyurlCom.py | 2 +- module/plugins/crypter/XFileSharingProFolder.py | 2 +- module/plugins/crypter/YoutubeComFolder.py | 2 +- module/plugins/hooks/Checksum.py | 4 +- module/plugins/hooks/ClickAndLoad.py | 122 ------------------------ module/plugins/hooks/ClickNLoad.py | 122 ++++++++++++++++++++++++ module/plugins/hooks/ExternalScripts.py | 6 +- module/plugins/hooks/HotFolder.py | 5 +- module/plugins/hooks/IRCInterface.py | 4 +- module/plugins/hooks/LinkdecrypterComHook.py | 2 +- module/plugins/hooks/MultiHome.py | 71 +++++++------- module/plugins/hooks/RestartFailed.py | 2 +- module/plugins/hooks/SkipRev.py | 2 +- module/plugins/hooks/XFileSharingPro.py | 4 +- module/plugins/hoster/Ftp.py | 2 +- module/plugins/hoster/LinksnappyCom.py | 2 +- module/plugins/hoster/MegaCoNz.py | 2 +- module/plugins/hoster/MegacrypterCom.py | 2 +- module/plugins/hoster/NarodRu.py | 4 +- module/plugins/hoster/NitroflareCom.py | 2 +- module/plugins/hoster/OpenloadIo.py | 2 +- module/plugins/hoster/RgHostNet.py | 2 +- module/plugins/hoster/SoundcloudCom.py | 2 +- module/plugins/hoster/UnibytesCom.py | 2 +- module/plugins/hoster/XFileSharingPro.py | 2 +- module/plugins/hoster/YadiSk.py | 2 +- module/plugins/hoster/ZippyshareCom.py | 2 +- module/plugins/internal/Addon.py | 7 +- module/plugins/internal/Base.py | 6 +- module/plugins/internal/Plugin.py | 8 +- module/plugins/internal/UnRar.py | 2 +- 44 files changed, 220 insertions(+), 211 deletions(-) delete mode 100644 module/plugins/hooks/ClickAndLoad.py create mode 100644 module/plugins/hooks/ClickNLoad.py (limited to 'module') diff --git a/module/plugins/accounts/FreakshareCom.py b/module/plugins/accounts/FreakshareCom.py index a319096db..8cb0436fc 100644 --- a/module/plugins/accounts/FreakshareCom.py +++ b/module/plugins/accounts/FreakshareCom.py @@ -25,7 +25,7 @@ class FreakshareCom(Account): html = self.load("http://freakshare.com/") try: - m = re.search(r'ltig bis:\s*([\d.:-]+)', html, re.M) + m = re.search(r'ltig bis:\s*([\d.:\-]+)', html, re.M) validuntil = time.mktime(time.strptime(m.group(1), "%d.%m.%Y - %H:%M")) except Exception: diff --git a/module/plugins/accounts/HellshareCz.py b/module/plugins/accounts/HellshareCz.py index 5423b212f..b0cd87938 100644 --- a/module/plugins/accounts/HellshareCz.py +++ b/module/plugins/accounts/HellshareCz.py @@ -59,7 +59,7 @@ class HellshareCz(Account): self.log_debug("Switch lang - URL: %s" % self.req.lastEffectiveURL) json = self.load("%s?do=locRouter-show" % self.req.lastEffectiveURL) - hash = re.search(r"(--[0-9a-f]+-)", json).group(1) + hash = re.search(r"(--[0-9a-f]+\-)", json).group(1) self.log_debug("Switch lang - HASH: %s" % hash) diff --git a/module/plugins/accounts/OneFichierCom.py b/module/plugins/accounts/OneFichierCom.py index 0249f2b93..42838690e 100644 --- a/module/plugins/accounts/OneFichierCom.py +++ b/module/plugins/accounts/OneFichierCom.py @@ -19,7 +19,7 @@ class OneFichierCom(Account): ("Walter Purcaro", "vuolter@gmail.com")] - VALID_UNTIL_PATTERN = r'Your subscription will end the (\d+-\d+-\d+)' + VALID_UNTIL_PATTERN = r'Your subscription will end the (\d+\-\d+\-\d+)' def grab_info(self, user, password, data): diff --git a/module/plugins/captcha/AdYouLike.py b/module/plugins/captcha/AdYouLike.py index cac73774a..b10d2c399 100644 --- a/module/plugins/captcha/AdYouLike.py +++ b/module/plugins/captcha/AdYouLike.py @@ -31,7 +31,7 @@ class AdYouLike(CaptchaService): self.log_debug("Ayl: %s | Callback: %s" % self.key) return self.key #: Key is the tuple(ayl, callback) else: - self.log_warning(_("Ayl or callback pattern not found")) + self.log_debug("Ayl or callback pattern not found") return None diff --git a/module/plugins/captcha/AdsCaptcha.py b/module/plugins/captcha/AdsCaptcha.py index 613283e53..7dc51565f 100644 --- a/module/plugins/captcha/AdsCaptcha.py +++ b/module/plugins/captcha/AdsCaptcha.py @@ -18,7 +18,7 @@ class AdsCaptcha(CaptchaService): CAPTCHAID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?.*?CaptchaId=(\d+)' - PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?.*?PublicKey=([\w-]+)' + PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?.*?PublicKey=([\w\-]+)' def detect_key(self, data=None): @@ -31,7 +31,7 @@ class AdsCaptcha(CaptchaService): self.log_debug("Key: %s | ID: %s" % self.key) return self.key else: - self.log_warning(_("Key or id pattern not found")) + self.log_debug("Key or id pattern not found") return None diff --git a/module/plugins/captcha/ReCaptcha.py b/module/plugins/captcha/ReCaptcha.py index a3ac52cb1..379956be6 100644 --- a/module/plugins/captcha/ReCaptcha.py +++ b/module/plugins/captcha/ReCaptcha.py @@ -23,8 +23,8 @@ class ReCaptcha(CaptchaService): ("zapp-brannigan", "fuerst.reinje@web.de")] - KEY_V1_PATTERN = r'(?:recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=|Recaptcha\.create\s*\(\s*["\'])([\w-]+)' - KEY_V2_PATTERN = r'(?:data-sitekey=["\']|["\']sitekey["\']:\s*["\'])([\w-]+)' + KEY_V1_PATTERN = r'(?:recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=|Recaptcha\.create\s*\(\s*["\'])([\w\-]+)' + KEY_V2_PATTERN = r'(?:data-sitekey=["\']|["\']sitekey["\']:\s*["\'])([\w\-]+)' def detect_key(self, data=None): diff --git a/module/plugins/captcha/SolveMedia.py b/module/plugins/captcha/SolveMedia.py index a5a49b68e..302d229b8 100644 --- a/module/plugins/captcha/SolveMedia.py +++ b/module/plugins/captcha/SolveMedia.py @@ -29,7 +29,7 @@ class SolveMedia(CaptchaService): self.log_debug("Key: %s" % self.key) return self.key else: - self.log_warning(_("Key pattern not found")) + self.log_debug("Key pattern not found") return None diff --git a/module/plugins/crypter/Dereferer.py b/module/plugins/crypter/Dereferer.py index 0a1c1a918..8ecc635ec 100644 --- a/module/plugins/crypter/Dereferer.py +++ b/module/plugins/crypter/Dereferer.py @@ -11,7 +11,7 @@ class Dereferer(SimpleCrypter): __version__ = "0.19" __status__ = "testing" - __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*?(?P(?:[\d.]+|[\w-]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/.*?(?P(?:ht|f)tps?://.+)' + __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*?(?P(?:[\d.]+|[\w\-]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/.*?(?P(?:ht|f)tps?://.+)' __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), ("subfolder_per_pack", "bool", "Create a subfolder for each package", True)] diff --git a/module/plugins/crypter/FilecryptCc.py b/module/plugins/crypter/FilecryptCc.py index 70f9bc088..51fdcd30b 100644 --- a/module/plugins/crypter/FilecryptCc.py +++ b/module/plugins/crypter/FilecryptCc.py @@ -31,7 +31,7 @@ class FilecryptCc(Crypter): # URL_REPLACEMENTS = [(r'.html$', ""), (r'$', ".html")] #@TODO: Extend SimpleCrypter DLC_LINK_PATTERN = r'onclick="DownloadDLC\(\'(.+)\'\);">' - WEBLINK_PATTERN = r"openLink.?'([\w-]*)'," + WEBLINK_PATTERN = r"openLink.?'([\w\-]*)'," CAPTCHA_PATTERN = r'class="safety">Sicherheitsabfrage<' INTERNAL_CAPTCHA_PATTERN = r'(?:[\d.]+|[\w-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+' + __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*?(?P(?:[\d.]+|[\w\-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+' __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), ("subfolder_per_pack", "bool", "Create a subfolder for each package", True)] diff --git a/module/plugins/crypter/YoutubeComFolder.py b/module/plugins/crypter/YoutubeComFolder.py index ea09c63f9..302f18ac0 100644 --- a/module/plugins/crypter/YoutubeComFolder.py +++ b/module/plugins/crypter/YoutubeComFolder.py @@ -14,7 +14,7 @@ class YoutubeComFolder(Crypter): __version__ = "1.03" __status__ = "testing" - __pattern__ = r'https?://(?:www\.|m\.)?youtube\.com/(?Puser|playlist|view_play_list)(/|.*?[?&](?:list|p)=)(?P[\w-]+)' + __pattern__ = r'https?://(?:www\.|m\.)?youtube\.com/(?Puser|playlist|view_play_list)(/|.*?[?&](?:list|p)=)(?P[\w\-]+)' __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True ), ("subfolder_per_pack", "bool", "Create a subfolder for each package", True ), ("likes" , "bool", "Grab user (channel) liked videos" , False), diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 2a650768e..fe866563d 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -160,7 +160,8 @@ class Checksum(Addon): return elif check_action == "nothing": return - pyfile.plugin.fail(msg=msg) + + pyfile.plugin.fail(msg) def package_finished(self, pypack): @@ -187,6 +188,7 @@ class Checksum(Addon): local_file = fs_encode(fs_join(download_folder, data['NAME'])) algorithm = self.methods.get(file_type, file_type) checksum = compute_checksum(local_file, algorithm) + if checksum is data['HASH']: self.log_info(_('File integrity of "%s" verified by %s checksum (%s)') % (data['NAME'], algorithm, checksum)) diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py deleted file mode 100644 index aef014d1a..000000000 --- a/module/plugins/hooks/ClickAndLoad.py +++ /dev/null @@ -1,122 +0,0 @@ -# -*- coding: utf-8 -*- - -import socket -import time - -try: - import ssl -except ImportError: - pass - -from threading import Lock - -from module.plugins.internal.Addon import Addon, threaded - - -def forward(source, destination): - try: - bufsize = 1024 - bufdata = source.recv(bufsize) - while bufdata: - destination.sendall(bufdata) - bufdata = source.recv(bufsize) - finally: - destination.shutdown(socket.SHUT_WR) - #: destination.close() - - -#@TODO: IPv6 support -class ClickAndLoad(Addon): - __name__ = "ClickAndLoad" - __type__ = "hook" - __version__ = "0.48" - __status__ = "testing" - - __config__ = [("activated", "bool" , "Activated" , True ), - ("port" , "int" , "Port" , 9666 ), - ("extern" , "bool" , "Listen for external connections", True ), - ("dest" , "queue;collector", "Add packages to" , "collector")] - - __description__ = """Click'n'Load hook plugin""" - __license__ = "GPLv3" - __authors__ = [("RaNaN" , "RaNaN@pyload.de" ), - ("Walter Purcaro", "vuolter@gmail.com")] - - - def activate(self): - if not self.pyload.config.get("webinterface", "activated"): - return - - ip = "" if self.get_config('extern') else "127.0.0.1" - webport = self.pyload.config.get("webinterface", "port") - cnlport = self.get_config('port') - - self.proxy(ip, webport, cnlport) - - - @threaded - def forward(self, source, destination, queue=False): - if queue: - old_ids = set(pack.id for pack in self.pyload.api.getCollector()) - - forward(source, destination) - - if queue: - new_ids = set(pack.id for pack in self.pyload.api.getCollector()) - for id in new_ids - old_ids: - self.pyload.api.pushToQueue(id) - - - @threaded - def proxy(self, ip, webport, cnlport): - time.sleep(10) #@TODO: Remove in 0.4.10 (implement addon delay on startup) - - self.log_info(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) - - self._server(ip, webport, cnlport) - - lock = Lock() - lock.acquire() - lock.acquire() - - - @threaded - def _server(self, ip, webport, cnlport): - try: - dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - dock_socket.bind((ip, cnlport)) - dock_socket.listen(5) - - while True: - client_socket, client_addr = dock_socket.accept() - self.log_debug("Connection from %s:%s" % client_addr) - - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - if self.pyload.config.get("webinterface", "https"): - try: - server_socket = ssl.wrap_socket(server_socket) - - except NameError: - self.log_error(_("Missing SSL lib"), _("Please disable HTTPS in pyLoad settings")) - client_socket.close() - continue - - except Exception, e: - self.log_error(_("SSL error: %s") % e.message) - client_socket.close() - continue - - server_socket.connect(("127.0.0.1", webport)) - - self.forward(client_socket, server_socket, self.get_config('dest') is "queue") - self.forward(server_socket, client_socket) - - except socket.timeout: - self.log_debug("Connection timed out, retrying...") - return self._server(ip, webport, cnlport) - - except socket.error, e: - self.log_error(e) - time.sleep(240) - return self._server(ip, webport, cnlport) diff --git a/module/plugins/hooks/ClickNLoad.py b/module/plugins/hooks/ClickNLoad.py new file mode 100644 index 000000000..13975ecb5 --- /dev/null +++ b/module/plugins/hooks/ClickNLoad.py @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- + +import socket +import time + +try: + import ssl +except ImportError: + pass + +from threading import Lock + +from module.plugins.internal.Addon import Addon, threaded + + +def forward(source, destination): + try: + bufsize = 1024 + bufdata = source.recv(bufsize) + while bufdata: + destination.sendall(bufdata) + bufdata = source.recv(bufsize) + finally: + destination.shutdown(socket.SHUT_WR) + #: destination.close() + + +#@TODO: IPv6 support +class ClickNLoad(Addon): + __name__ = "ClickNLoad" + __type__ = "hook" + __version__ = "0.48" + __status__ = "testing" + + __config__ = [("activated", "bool" , "Activated" , True ), + ("port" , "int" , "Port" , 9666 ), + ("extern" , "bool" , "Listen for external connections", True ), + ("dest" , "queue;collector", "Add packages to" , "collector")] + + __description__ = """Click'n'Load hook plugin""" + __license__ = "GPLv3" + __authors__ = [("RaNaN" , "RaNaN@pyload.de" ), + ("Walter Purcaro", "vuolter@gmail.com")] + + + def activate(self): + if not self.pyload.config.get("webinterface", "activated"): + return + + ip = "" if self.get_config('extern') else "127.0.0.1" + webport = self.pyload.config.get("webinterface", "port") + cnlport = self.get_config('port') + + self.proxy(ip, webport, cnlport) + + + @threaded + def forward(self, source, destination, queue=False): + if queue: + old_ids = set(pack.id for pack in self.pyload.api.getCollector()) + + forward(source, destination) + + if queue: + new_ids = set(pack.id for pack in self.pyload.api.getCollector()) + for id in new_ids - old_ids: + self.pyload.api.pushToQueue(id) + + + @threaded + def proxy(self, ip, webport, cnlport): + time.sleep(10) #@TODO: Remove in 0.4.10 (implement addon delay on startup) + + self.log_info(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) + + self._server(ip, webport, cnlport) + + lock = Lock() + lock.acquire() + lock.acquire() + + + @threaded + def _server(self, ip, webport, cnlport): + try: + dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket.bind((ip, cnlport)) + dock_socket.listen(5) + + while True: + client_socket, client_addr = dock_socket.accept() + self.log_debug("Connection from %s:%s" % client_addr) + + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + if self.pyload.config.get("webinterface", "https"): + try: + server_socket = ssl.wrap_socket(server_socket) + + except NameError: + self.log_error(_("Missing SSL lib"), _("Please disable HTTPS in pyLoad settings")) + client_socket.close() + continue + + except Exception, e: + self.log_error(_("SSL error: %s") % e.message) + client_socket.close() + continue + + server_socket.connect(("127.0.0.1", webport)) + + self.forward(client_socket, server_socket, self.get_config('dest') is "queue") + self.forward(server_socket, client_socket) + + except socket.timeout: + self.log_debug("Connection timed out, retrying...") + return self._server(ip, webport, cnlport) + + except socket.error, e: + self.log_error(e) + time.sleep(240) + return self._server(ip, webport, cnlport) diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 32faebbed..09fe59d0a 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -11,7 +11,7 @@ from module.utils import fs_encode, save_join as fs_join class ExternalScripts(Addon): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.48" + __version__ = "0.49" __status__ = "testing" __config__ = [("activated", "bool", "Activated" , True ), @@ -26,7 +26,6 @@ class ExternalScripts(Addon): def init(self): - self.info['oldip'] = None self.scripts = {} self.event_list = ["archive_extract_failed", "archive_extracted" , @@ -115,13 +114,12 @@ class ExternalScripts(Addon): for script in self.scripts['before_reconnect']: args = [ip] self.call(script, args, lock) - self.info['oldip'] = ip def after_reconnect(self, ip, oldip): lock = self.get_config('lock') for script in self.scripts['after_reconnect']: - args = [ip, self.info['oldip']] #@TODO: Use built-in oldip in 0.4.10 + args = [ip, oldip] self.call(script, args, lock) diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index d556537aa..aeb432626 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -3,10 +3,9 @@ from __future__ import with_statement import os +import shutil import time -from shutil import move - from module.plugins.internal.Addon import Addon from module.utils import fs_encode, save_join as fs_join @@ -63,7 +62,7 @@ class HotFolder(Addon): continue newpath = os.path.join(folder, "finished", "tmp_" + f if self.get_config('delete') else f) - move(path, newpath) + shutil.move(path, newpath) self.log_info(_("Added %s from HotFolder") % f) self.pyload.api.addPackage(f, [newpath], 1) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index c84c0439d..6135b3244 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -2,12 +2,12 @@ import pycurl import re +import select import socket import ssl import time import traceback -from select import select from threading import Thread from module.Api import PackageDoesNotExists, FileDoesNotExists @@ -114,7 +114,7 @@ class IRCInterface(Thread, Addon): readbuffer = "" while True: time.sleep(1) - fdset = select([self.sock], [], [], 0) + fdset = select.select([self.sock], [], [], 0) if self.sock not in fdset[0]: continue diff --git a/module/plugins/hooks/LinkdecrypterComHook.py b/module/plugins/hooks/LinkdecrypterComHook.py index 7d39656d3..a318a78fa 100644 --- a/module/plugins/hooks/LinkdecrypterComHook.py +++ b/module/plugins/hooks/LinkdecrypterComHook.py @@ -23,7 +23,7 @@ class LinkdecrypterComHook(Addon): def get_hosters(self): - list = re.search(r'>Supported\(\d+\): (.[\w.-, ]+)', + list = re.search(r'>Supported\(\d+\): (.[\w\-., ]+)', self.load("http://linkdecrypter.com/").replace("(g)", "")).group(1).split(', ') try: list.remove("download.serienjunkies.org") diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 929ab9a25..b1e3c8ada 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -5,6 +5,42 @@ import time from module.plugins.internal.Addon import Addon +def get_request(pluginName, account=None): + iface = self.best_interface(pluginName, account) + + if not iface: + return + + iface.useFor(pluginName, account) + requestFactory.iface = lambda: iface.adress + self.log_debug("Using address", iface.adress) + + return oldGetRequest(pluginName, account) + + +class Interface(object): + + def __init__(self, adress): + self.adress = adress + self.history = {} + + + def last_plugin_access(self, pluginName, account): + if (pluginName, account) in self.history: + return self.history[(pluginName, account)] + else: + return 0 + + + def use_for(self, pluginName, account): + self.history[(pluginName, account)] = time.time() + + + def __repr__(self): + return "" % self.adress + + + class MultiHome(Addon): __name__ = "MultiHome" __type__ = "hook" @@ -42,44 +78,15 @@ class MultiHome(Addon): def activate(self): requestFactory = self.pyload.requestFactory - oldGetRequest = requestFactory.getRequest - - - def get_request(pluginName, account=None): - iface = self.best_interface(pluginName, account) - if iface: - iface.useFor(pluginName, account) - requestFactory.iface = lambda: iface.adress - self.log_debug("Using address", iface.adress) - return oldGetRequest(pluginName, account) - + oldGetRequest = requestFactory.getRequest requestFactory.getRequest = get_request def best_interface(self, pluginName, account): best = None + for interface in self.interfaces: if not best or interface.lastPluginAccess(pluginName, account) < best.lastPluginAccess(pluginName, account): best = interface - return best - - -class Interface(object): - - def __init__(self, adress): - self.adress = adress - self.history = {} - - def last_plugin_access(self, pluginName, account): - if (pluginName, account) in self.history: - return self.history[(pluginName, account)] - return 0 - - - def use_for(self, pluginName, account): - self.history[(pluginName, account)] = time.time() - - - def __repr__(self): - return "" % self.adress + return best diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 812b68f76..e1498b0ae 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -20,7 +20,7 @@ class RestartFailed(Addon): def periodical(self): - self.log_debug("Restart failed downloads") + self.log_info(_("Restarting all failed downloads...")) self.pyload.api.restartFailed() diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 5f9cfa452..1e0a495b4 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -74,7 +74,7 @@ class SkipRev(Addon): pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.')) for link in self.pyload.api.getPackageData(pyfile.package().id).links: - if link.status == 4 and pyname.match(link.name): + if link.status is 4 and pyname.match(link.name): pylink = self._pyfile(link) if revtokeep > -1 or pyfile.name.endswith(".rev"): diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 04438519b..70bafba67 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -23,9 +23,9 @@ class XFileSharingPro(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - regexp = {'hoster' : (r'https?://(?:www\.)?(?:\w+\.)*?(?P(?:[\d.]+|[\w-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', + regexp = {'hoster' : (r'https?://(?:www\.)?(?:\w+\.)*?(?P(?:[\d.]+|[\w\-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P%s)/(?:embed-)?\w+'), - 'crypter': (r'https?://(?:www\.)?(?:\w+\.)*?(?P(?:[\d.]+|[\w-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+', + 'crypter': (r'https?://(?:www\.)?(?:\w+\.)*?(?P(?:[\d.]+|[\w\-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+', r'https?://(?:[^/]+\.)?(?P%s)/(?:user|folder)s?/\w+')} BUILTIN_HOSTERS = [#WORKING HOSTERS: diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 2ff1755f4..79f72c868 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -14,7 +14,7 @@ class Ftp(Hoster): __version__ = "0.55" __status__ = "testing" - __pattern__ = r'(?:ftps?|sftp)://([\w.-]+(:[\w.-]+)?@)?[\w.-]+(:\d+)?/.+' + __pattern__ = r'(?:ftps?|sftp)://([\w\-.]+(:[\w\-.]+)?@)?[\w\-.]+(:\d+)?/.+' __description__ = """Download from ftp directory""" __license__ = "GPLv3" diff --git a/module/plugins/hoster/LinksnappyCom.py b/module/plugins/hoster/LinksnappyCom.py index f92681f60..3301eda7c 100644 --- a/module/plugins/hoster/LinksnappyCom.py +++ b/module/plugins/hoster/LinksnappyCom.py @@ -46,7 +46,7 @@ class LinksnappyCom(MultiHoster): @staticmethod def _get_host(url): host = urlparse.urlsplit(url).netloc - return re.search(r'[\w-]+\.\w+$', host).group(0) + return re.search(r'[\w\-]+\.\w+$', host).group(0) getInfo = create_getInfo(LinksnappyCom) diff --git a/module/plugins/hoster/MegaCoNz.py b/module/plugins/hoster/MegaCoNz.py index d8a29817c..784131842 100644 --- a/module/plugins/hoster/MegaCoNz.py +++ b/module/plugins/hoster/MegaCoNz.py @@ -51,7 +51,7 @@ class MegaCoNz(Hoster): __version__ = "0.31" __status__ = "testing" - __pattern__ = r'(https?://(?:www\.)?mega(\.co)?\.nz/|mega:|chrome:.+?)#(?PN|)!(?P[\w^_]+)!(?P[\w,-]+)' + __pattern__ = r'(https?://(?:www\.)?mega(\.co)?\.nz/|mega:|chrome:.+?)#(?PN|)!(?P[\w^_]+)!(?P[\w\-,]+)' __description__ = """Mega.co.nz hoster plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hoster/MegacrypterCom.py b/module/plugins/hoster/MegacrypterCom.py index a67dca5da..fc20890e4 100644 --- a/module/plugins/hoster/MegacrypterCom.py +++ b/module/plugins/hoster/MegacrypterCom.py @@ -13,7 +13,7 @@ class MegacrypterCom(MegaCoNz): __version__ = "0.23" __status__ = "testing" - __pattern__ = r'https?://\w{0,10}\.?megacrypter\.com/[\w!-]+' + __pattern__ = r'https?://\w{0,10}\.?megacrypter\.com/[\w\-!]+' __description__ = """Megacrypter.com decrypter plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hoster/NarodRu.py b/module/plugins/hoster/NarodRu.py index bea04c9cd..a6504025e 100644 --- a/module/plugins/hoster/NarodRu.py +++ b/module/plugins/hoster/NarodRu.py @@ -13,7 +13,7 @@ class NarodRu(SimpleHoster): __version__ = "0.13" __status__ = "testing" - __pattern__ = r'http://(?:www\.)?narod(\.yandex)?\.ru/(disk|start/\d+\.\w+-narod\.yandex\.ru)/(?P\d+)/.+' + __pattern__ = r'http://(?:www\.)?narod(\.yandex)?\.ru/(disk|start/\d+\.\w+\-narod\.yandex\.ru)/(?P\d+)/.+' __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """Narod.ru hoster plugin""" @@ -27,7 +27,7 @@ class NarodRu(SimpleHoster): SIZE_REPLACEMENTS = [(u'КБ', 'KB'), (u'МБ', 'MB'), (u'ГБ', 'GB')] URL_REPLACEMENTS = [("narod.yandex.ru/", "narod.ru/"), - (r"/start/\d+\.\w+-narod\.yandex\.ru/(\d{6,15})/\w+/(\w+)", r"/disk/\1/\2")] + (r"/start/\d+\.\w+\-narod\.yandex\.ru/(\d{6,15})/\w+/(\w+)", r"/disk/\1/\2")] CAPTCHA_PATTERN = r'(\w+)' LINK_FREE_PATTERN = r'' diff --git a/module/plugins/hoster/NitroflareCom.py b/module/plugins/hoster/NitroflareCom.py index 431698596..ad0573960 100644 --- a/module/plugins/hoster/NitroflareCom.py +++ b/module/plugins/hoster/NitroflareCom.py @@ -24,7 +24,7 @@ class NitroflareCom(SimpleHoster): INFO_PATTERN = r'title="(?P.+?)".+>(?P[\d.,]+) (?P[\w^_]+)' OFFLINE_PATTERN = r'>File doesn\'t exist' - LINK_PREMIUM_PATTERN = LINK_FREE_PATTERN = r'(https?://[\w-]+\.nitroflare\.com/.+?)"' + LINK_PREMIUM_PATTERN = LINK_FREE_PATTERN = r'(https?://[\w\-]+\.nitroflare\.com/.+?)"' RECAPTCHA_KEY = "6Lenx_USAAAAAF5L1pmTWvWcH73dipAEzNnmNLgy" PREMIUM_ONLY_PATTERN = r'This file is available with Premium only' diff --git a/module/plugins/hoster/OpenloadIo.py b/module/plugins/hoster/OpenloadIo.py index 842879203..fb552626c 100644 --- a/module/plugins/hoster/OpenloadIo.py +++ b/module/plugins/hoster/OpenloadIo.py @@ -13,7 +13,7 @@ class OpenloadIo(SimpleHoster): __version__ = "0.09" __status__ = "testing" - __pattern__ = r'https?://(?:www\.)?openload\.(co|io)/(f|embed)/(?P[\w-]+)' + __pattern__ = r'https?://(?:www\.)?openload\.(co|io)/(f|embed)/(?P[\w\-]+)' __description__ = """Openload.co hoster plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hoster/RgHostNet.py b/module/plugins/hoster/RgHostNet.py index 0aa4b7d73..124566b77 100644 --- a/module/plugins/hoster/RgHostNet.py +++ b/module/plugins/hoster/RgHostNet.py @@ -11,7 +11,7 @@ class RgHostNet(SimpleHoster): __version__ = "0.05" __status__ = "testing" - __pattern__ = r'http://(?:www\.)?rghost\.(net|ru)/[\d-]+' + __pattern__ = r'http://(?:www\.)?rghost\.(net|ru)/[\d\-]+' __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """RgHost.net hoster plugin""" diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index b189ee1ba..a7a45d028 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -12,7 +12,7 @@ class SoundcloudCom(SimpleHoster): __version__ = "0.12" __status__ = "testing" - __pattern__ = r'https?://(?:www\.)?soundcloud\.com/[\w-]+/[\w-]+' + __pattern__ = r'https?://(?:www\.)?soundcloud\.com/[\w\-]+/[\w\-]+' __config__ = [("use_premium", "bool" , "Use premium account if available", True ), ("quality" , "Lower;Higher", "Quality" , "Higher")] diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index 15b553162..c0bb6a13b 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -13,7 +13,7 @@ class UnibytesCom(SimpleHoster): __version__ = "0.16" __status__ = "testing" - __pattern__ = r'https?://(?:www\.)?unibytes\.com/[\w .-]{11}B' + __pattern__ = r'https?://(?:www\.)?unibytes\.com/[\w\- .]{11}B' __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """UniBytes.com hoster plugin""" diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py index a5d76763d..b2e5e7321 100644 --- a/module/plugins/hoster/XFileSharingPro.py +++ b/module/plugins/hoster/XFileSharingPro.py @@ -11,7 +11,7 @@ class XFileSharingPro(XFSHoster): __version__ = "0.54" __status__ = "testing" - __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*?(?P(?:[\d.]+|[\w-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)' + __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*?(?P(?:[\d.]+|[\w\-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)' __description__ = """XFileSharingPro dummy hoster plugin for hook""" __license__ = "GPLv3" diff --git a/module/plugins/hoster/YadiSk.py b/module/plugins/hoster/YadiSk.py index 354ba1b4c..418f38926 100644 --- a/module/plugins/hoster/YadiSk.py +++ b/module/plugins/hoster/YadiSk.py @@ -13,7 +13,7 @@ class YadiSk(SimpleHoster): __version__ = "0.06" __status__ = "testing" - __pattern__ = r'https?://yadi\.sk/d/[\w-]+' + __pattern__ = r'https?://yadi\.sk/d/[\w\-]+' __description__ = """Yadi.sk hoster plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 221ec8c42..306ea2fd3 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -81,7 +81,7 @@ class ZippyshareCom(SimpleHoster): return varName #: Handle all getElementById - reVar = r'document.getElementById\(([\'"\w-]+)\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' + reVar = r'document.getElementById\(([\'"\w\-]+)\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' scripts = [re.sub(reVar, repl_element_by_id, script) for script in scripts if script] #: Add try/catch in JS to handle deliberate errors diff --git a/module/plugins/internal/Addon.py b/module/plugins/internal/Addon.py index cf3f01df1..ae61acf65 100644 --- a/module/plugins/internal/Addon.py +++ b/module/plugins/internal/Addon.py @@ -23,7 +23,7 @@ def threaded(fn): class Addon(Plugin): __name__ = "Addon" __type__ = "hook" #@TODO: Change to `addon` in 0.4.10 - __version__ = "0.07" + __version__ = "0.08" __status__ = "testing" __threaded__ = [] #@TODO: Remove in 0.4.10 @@ -46,6 +46,8 @@ class Addon(Plugin): #: List of events the plugin can handle, name the functions exactly like eventname. self.event_list = [] #@NOTE: dont make duplicate entries in event_map + self.info['ip'] = None #@TODO: Remove in 0.4.10 + #: Callback of periodical job task, used by HookManager self.cb = None self.interval = 60 @@ -210,7 +212,8 @@ class Addon(Plugin): #: Deprecated method, use `after_reconnect` instead (Remove in 0.4.10) def afterReconnecting(self, ip): - return self.after_reconnect(ip, None) + self.after_reconnect(ip, self.info['ip']) + self.info['ip'] = ip def captcha_task(self, task): diff --git a/module/plugins/internal/Base.py b/module/plugins/internal/Base.py index 28bc47556..51be82bd4 100644 --- a/module/plugins/internal/Base.py +++ b/module/plugins/internal/Base.py @@ -52,7 +52,7 @@ def check_abort(fn): class Base(Plugin): __name__ = "Base" __type__ = "base" - __version__ = "0.03" + __version__ = "0.04" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -110,7 +110,7 @@ class Base(Plugin): @classmethod def get_info(cls, url="", html=""): - url = fixurl(url) + url = fixurl(url, unquote=True) info = {'name' : parse_name(url), 'size' : 0, 'status': 3 if url else 8, @@ -378,7 +378,7 @@ class Base(Plugin): def fixurl(self, url, baseurl=None, unquote=True): - url = fixurl(url) + url = fixurl(url, unquote=False) if not baseurl: baseurl = fixurl(self.pyfile.url) diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py index 9d2aa8b50..d89c3d2c0 100644 --- a/module/plugins/internal/Plugin.py +++ b/module/plugins/internal/Plugin.py @@ -60,7 +60,7 @@ def fixurl(url, unquote=None): if unquote is None: unquote = newurl == url - newurl = html_unescape(newurl.decode('unicode-escape')) + newurl = html_unescape(decode(newurl).decode('unicode-escape')) newurl = re.sub(r'(?