From ffd38f027ed103f7b39ec78c6af0d182774950a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 19 Oct 2015 04:48:07 +0200 Subject: Spare fixes --- module/plugins/hoster/GoogledriveCom.py | 4 +- module/plugins/hoster/Http.py | 46 +++++++++----------- module/plugins/hoster/Share4WebCom.py | 3 +- module/plugins/hoster/XFileSharing.py | 73 +++++++++++++++++++++++++++++++ module/plugins/hoster/XFileSharingPro.py | 75 -------------------------------- 5 files changed, 96 insertions(+), 105 deletions(-) create mode 100644 module/plugins/hoster/XFileSharing.py delete mode 100644 module/plugins/hoster/XFileSharingPro.py (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/GoogledriveCom.py b/module/plugins/hoster/GoogledriveCom.py index 00a540e47..6b49a45a6 100644 --- a/module/plugins/hoster/GoogledriveCom.py +++ b/module/plugins/hoster/GoogledriveCom.py @@ -13,7 +13,7 @@ from module.plugins.internal.utils import html_unescape class GoogledriveCom(SimpleHoster): __name__ = "GoogledriveCom" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.16" __status__ = "testing" __pattern__ = r'https?://(?:www\.)?(drive|docs)\.google\.com/(file/d/\w+|uc\?.*id=)' @@ -45,7 +45,7 @@ class GoogledriveCom(SimpleHoster): return link = self.fixurl(link, "https://docs.google.com/") - dl = self.is_download(link, redirect=False) + dl = self.isdownload(link, redirect=False) if not dl: self.html = self.load(link) diff --git a/module/plugins/hoster/Http.py b/module/plugins/hoster/Http.py index 4e7ad0316..af82ca0ac 100644 --- a/module/plugins/hoster/Http.py +++ b/module/plugins/hoster/Http.py @@ -3,14 +3,13 @@ import re import urlparse -from module.network.HTTPRequest import BadHeader from module.plugins.internal.Hoster import Hoster, create_getInfo class Http(Hoster): __name__ = "Http" __type__ = "hoster" - __version__ = "0.02" + __version__ = "0.03" __status__ = "testing" __pattern__ = r'(?:jd|pys?)://.+' @@ -30,41 +29,36 @@ class Http(Hoster): url = re.sub(r'^(jd|py)', "http", pyfile.url) netloc = urlparse.urlparse(url).netloc - link = self.is_download(url) + link = self.isdownload(url) if not link: return for _i in xrange(2): - try: - self.download(link, ref=False, disposition=True) + self.download(link, ref=False, disposition=True) - except BadHeader, e: - if e.code in (404, 410): - self.offline() + if self.req.code in (404, 410): + self.offline() - elif e.code in (401, 403): - self.log_debug("Auth required", "Received HTTP status code: %d" % e.code) + elif self.req.code in (401, 403): + self.log_debug("Auth required", "Received HTTP status code: %d" % e.code) - #@TODO: Recheck in 0.4.10 - if self.account: - servers = [x['login'] for x in self.account.getAllAccounts()] - else: - servers = [] + #@TODO: Recheck in 0.4.10 + if self.account: + servers = [x['login'] for x in self.account.getAllAccounts()] + else: + servers = [] - if netloc in servers: - self.log_debug("Logging on to %s" % netloc) - self.req.addAuth(self.account.get_login('password')) + if netloc in servers: + self.log_debug("Logging on to %s" % netloc) + self.req.addAuth(self.account.get_login('password')) - else: - pwd = self.get_password() - if ':' in pwd: - self.req.addAuth(pwd) - else: - self.fail(_("Authorization required")) else: - self.fail(e) - + pwd = self.get_password() + if ':' in pwd: + self.req.addAuth(pwd) + else: + self.fail(_("Authorization required")) else: break diff --git a/module/plugins/hoster/Share4WebCom.py b/module/plugins/hoster/Share4WebCom.py index fa4861a89..f8d8a52d6 100644 --- a/module/plugins/hoster/Share4WebCom.py +++ b/module/plugins/hoster/Share4WebCom.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.UnibytesCom import UnibytesCom -from module.plugins.internal.SimpleHoster import create_getInfo +from module.plugins.hoster.UnibytesCom import UnibytesCom, create_getInfo class Share4WebCom(UnibytesCom): diff --git a/module/plugins/hoster/XFileSharing.py b/module/plugins/hoster/XFileSharing.py new file mode 100644 index 000000000..89b58bb7f --- /dev/null +++ b/module/plugins/hoster/XFileSharing.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class XFileSharing(XFSHoster): + __name__ = "XFileSharing" + __type__ = "hoster" + __version__ = "0.57" + __status__ = "testing" + + __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)' + __config__ = [("activated", "bool", "Activated", True)] + + __description__ = """XFileSharing dummy hoster plugin for hook""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + URL_REPLACEMENTS = [("/embed-", "/")] + + + def _log(self, level, plugintype, pluginname, messages): + messages = (self.PLUGIN_NAME,) + messages + return self.plugin._log(level, plugintype, pluginname, messages) + + + def init(self): + self.__pattern__ = self.pyload.pluginManager.hosterPlugins[self.classname]['pattern'] + + self.PLUGIN_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() + self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+|-)', self.PLUGIN_DOMAIN) if part != '.') + + + def _setup(self): + account_name = self.classname if not self.account or self.account.PLUGIN_DOMAIN is None else self.PLUGIN_NAME + self.chunk_limit = 1 + self.multiDL = True + + if self.account: + self.req = self.pyload.requestFactory.getRequest(accountname, self.account.user) + self.premium = self.account.premium + self.resume_download = self.premium + else: + self.req = self.pyload.requestFactory.getRequest(account_name) + self.premium = False + self.resume_download = False + + + def load_account(self): + if self.req: + self.req.close() + + if not self.account: + self.account = self.pyload.accountManager.getAccountPlugin(self.PLUGIN_NAME) + + if not self.account: + self.account = self.pyload.accountManager.getAccountPlugin(self.classname) + + if self.account: + if not self.account.PLUGIN_DOMAIN: + self.account.PLUGIN_DOMAIN = self.PLUGIN_DOMAIN + + if not self.account.user: #@TODO: Move to `Account` in 0.4.10 + self.account.user = self.account.select()[0] + + if not self.account.logged: + self.account = False + + +getInfo = create_getInfo(XFileSharing) diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py deleted file mode 100644 index 8721aae3a..000000000 --- a/module/plugins/hoster/XFileSharingPro.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo - - -class XFileSharingPro(XFSHoster): - __name__ = "XFileSharingPro" - __type__ = "hoster" - __version__ = "0.57" - __status__ = "testing" - - __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)' - __config__ = [("activated", "bool", "Activated", True)] - - __description__ = """XFileSharingPro dummy hoster plugin for hook""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - URL_REPLACEMENTS = [("/embed-", "/")] - - - def _log(self, level, plugintype, pluginname, messages): - return super(XFileSharingPro, self)._log(level, - plugintype, - "%s: %s" % (pluginname, self.PLUGIN_NAME), - messages) - - - def init(self): - self.__pattern__ = self.pyload.pluginManager.hosterPlugins[self.classname]['pattern'] - - self.PLUGIN_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() - self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+|-)', self.PLUGIN_DOMAIN) if part != '.') - - - def _setup(self): - account_name = self.classname if not self.account or self.account.PLUGIN_DOMAIN is None else self.PLUGIN_NAME - self.chunk_limit = 1 - self.multiDL = True - - if self.account: - self.req = self.pyload.requestFactory.getRequest(accountname, self.account.user) - self.premium = self.account.premium - self.resume_download = self.premium - else: - self.req = self.pyload.requestFactory.getRequest(account_name) - self.premium = False - self.resume_download = False - - - def load_account(self): - if self.req: - self.req.close() - - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.PLUGIN_NAME) - - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.classname) - - if self.account: - if not self.account.PLUGIN_DOMAIN: - self.account.PLUGIN_DOMAIN = self.PLUGIN_DOMAIN - - if not self.account.user: #@TODO: Move to `Account` in 0.4.10 - self.account.user = self.account.select()[0] - - if not self.account.logged: - self.account = False - - -getInfo = create_getInfo(XFileSharingPro) -- cgit v1.2.3