From b65c4091d5c5e793d8a9df17a46657d45c3a1292 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Mon, 24 Sep 2012 23:54:50 +0200 Subject: multihosters - closed #618, store http/ftp accounts, add uptobox.com premium --- module/plugins/hoster/BasePlugin.py | 58 ++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'module/plugins/hoster/BasePlugin.py') diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index 1ac33931f..14dfbba62 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -12,10 +12,10 @@ class BasePlugin(Hoster): __name__ = "BasePlugin" __type__ = "hoster" __pattern__ = r"^unmatchable$" - __version__ = "0.151" + __version__ = "0.16" __description__ = """Base Plugin when any other didnt fit""" - __author_name__ = ("RaNaN", 'hagg') - __author_mail__ = ("RaNaN@pyload.org", '') + __author_name__ = ("RaNaN") + __author_mail__ = ("RaNaN@pyload.org") def setup(self): self.chunkLimit = -1 @@ -47,15 +47,22 @@ class BasePlugin(Hoster): except BadHeader, e: if e.code in (401, 403): self.logDebug("Auth required") - - pwd = pyfile.package().password.strip() - if ":" not in pwd: - self.fail(_("Authorization required (username:password)")) - - self.req.addAuth(pwd) + + servers = [ x['login'] for x in core.accountManager.getAccountPlugin('Http').getAllAccounts() ] + server = urlparse(pyfile.url).netloc + + if server in servers: + self.logDebug("Logging on to %s" % server) + self.req.addAuth(self.account.accounts[server]["password"]) + else: + for pwd in pyfile.package().password.splitlines() + if ":" in pwd: + self.req.addAuth(pwd.strip()) + break + else: + self.fail(_("Authorization required (username:password)")) + self.downloadFile(pyfile) - elif e.code == 404: - self.offline() else: raise @@ -64,18 +71,21 @@ class BasePlugin(Hoster): def downloadFile(self, pyfile): - header = self.load(pyfile.url, just_header = True) - #self.logDebug(header) - - # self.load does not raise a BadHeader on 404 responses, do it here - if header.has_key('code') and header['code'] == 404: - raise BadHeader(404) - - if 'location' in header: - self.logDebug("Location: " + header['location']) - url = unquote(header['location']) - else: - url = pyfile.url + url = pyfile.url + + for i in range(5): + header = self.load(pyfile.url, just_header = True) + + # self.load does not raise a BadHeader on 404 responses, do it here + if header.has_key('code') and header['code'] == 404: + raise BadHeader(404) + + if 'location' in header: + self.logDebug("Location: " + header['location']) + url = unquote(header['location']) + self.logDebug("URL: %s" % url, html_unescape(unquote(urlparse(url).path.split("/")[-1]))) + else: + break name = html_unescape(unquote(urlparse(url).path.split("/")[-1])) @@ -92,4 +102,4 @@ class BasePlugin(Hoster): if not name: name = url pyfile.name = name self.logDebug("Filename: %s" % pyfile.name) - self.download(url, disposition=True) + self.download(url, disposition=True) \ No newline at end of file -- cgit v1.2.3 From 233bf90feb2941ecacee56966fdee2cd2f65d7b2 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Tue, 25 Sep 2012 19:07:51 +0200 Subject: small plugin fixes --- module/plugins/hoster/BasePlugin.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/BasePlugin.py') diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index 14dfbba62..7d6990c8b 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -55,7 +55,7 @@ class BasePlugin(Hoster): self.logDebug("Logging on to %s" % server) self.req.addAuth(self.account.accounts[server]["password"]) else: - for pwd in pyfile.package().password.splitlines() + for pwd in pyfile.package().password.splitlines(): if ":" in pwd: self.req.addAuth(pwd.strip()) break @@ -74,7 +74,7 @@ class BasePlugin(Hoster): url = pyfile.url for i in range(5): - header = self.load(pyfile.url, just_header = True) + header = self.load(url, just_header = True) # self.load does not raise a BadHeader on 404 responses, do it here if header.has_key('code') and header['code'] == 404: @@ -83,7 +83,6 @@ class BasePlugin(Hoster): if 'location' in header: self.logDebug("Location: " + header['location']) url = unquote(header['location']) - self.logDebug("URL: %s" % url, html_unescape(unquote(urlparse(url).path.split("/")[-1]))) else: break -- cgit v1.2.3 From ae900540bd98abd5b8f6e627fbff52586f34872b Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Sat, 17 Nov 2012 22:32:17 +0100 Subject: BasePlugin - fix http auth --- module/plugins/hoster/BasePlugin.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'module/plugins/hoster/BasePlugin.py') diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index 7d6990c8b..f8d494e39 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -12,7 +12,7 @@ class BasePlugin(Hoster): __name__ = "BasePlugin" __type__ = "hoster" __pattern__ = r"^unmatchable$" - __version__ = "0.16" + __version__ = "0.17" __description__ = """Base Plugin when any other didnt fit""" __author_name__ = ("RaNaN") __author_mail__ = ("RaNaN@pyload.org") @@ -47,21 +47,22 @@ class BasePlugin(Hoster): except BadHeader, e: if e.code in (401, 403): self.logDebug("Auth required") - - servers = [ x['login'] for x in core.accountManager.getAccountPlugin('Http').getAllAccounts() ] + + account = self.core.accountManager.getAccountPlugin('Http') + servers = [ x['login'] for x in account.getAllAccounts() ] server = urlparse(pyfile.url).netloc - + if server in servers: - self.logDebug("Logging on to %s" % server) - self.req.addAuth(self.account.accounts[server]["password"]) + self.logDebug("Logging on to %s" % server) + self.req.addAuth(account.accounts[server]["password"]) else: - for pwd in pyfile.package().password.splitlines(): + for pwd in pyfile.package().password.splitlines(): if ":" in pwd: self.req.addAuth(pwd.strip()) - break - else: + break + else: self.fail(_("Authorization required (username:password)")) - + self.downloadFile(pyfile) else: raise @@ -72,19 +73,19 @@ class BasePlugin(Hoster): def downloadFile(self, pyfile): url = pyfile.url - + for i in range(5): header = self.load(url, just_header = True) - + # self.load does not raise a BadHeader on 404 responses, do it here if header.has_key('code') and header['code'] == 404: raise BadHeader(404) - + if 'location' in header: self.logDebug("Location: " + header['location']) url = unquote(header['location']) else: - break + break name = html_unescape(unquote(urlparse(url).path.split("/")[-1])) -- cgit v1.2.3