From e2e96af3b35192107d32cc48d25c6c2aa6f822ba Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 23 Nov 2014 01:27:42 +0100 Subject: [BasePlugin] Improve a bit --- module/plugins/hoster/BasePlugin.py | 85 ++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 35 deletions(-) (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index 63714c437..27e8d050a 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -6,20 +6,27 @@ from urllib import unquote from urlparse import urlparse from module.network.HTTPRequest import BadHeader +from module.plugins.internal.SimpleHoster import create_getInfo from module.plugins.Hoster import Hoster -from module.utils import html_unescape, remove_chars +from module.utils import remove_chars class BasePlugin(Hoster): __name__ = "BasePlugin" __type__ = "hoster" - __version__ = "0.20" + __version__ = "0.21" __pattern__ = r'^unmatchable$' __description__ = """Base Plugin when any other didnt fit""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org")] + __authors__ = [("RaNaN", "RaNaN@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com")]] + + + @classmethod + def getInfo(cls, url="", html=""): #@TODO: Move to hoster class in 0.4.10 + return {'name': urlparse(url).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3, 'url': url or ""} def setup(self): @@ -30,40 +37,42 @@ class BasePlugin(Hoster): def process(self, pyfile): """main function""" - #: debug part, for api exerciser - if pyfile.url.startswith("DEBUG_API"): - self.multiDL = False - return + self.getInfo(pyfile.url) if pyfile.url.startswith("http"): + for _i in xrange(2): + try: + self.downloadFile(pyfile) - try: - self.downloadFile(pyfile) - except BadHeader, e: - if e.code in (401, 403): - self.logDebug("Auth required") + except BadHeader, e: + if e.code is 404: + self.offline() - account = self.core.accountManager.getAccountPlugin('Http') - servers = [x['login'] for x in account.getAllAccounts()] - server = urlparse(pyfile.url).netloc + elif e.code in (401, 403): + self.logDebug("Auth required") - if server in servers: - self.logDebug("Logging on to %s" % server) - self.req.addAuth(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)")) + account = self.core.accountManager.getAccountPlugin('Http') + servers = [x['login'] for x in account.getAllAccounts()] + server = urlparse(pyfile.url).netloc - self.downloadFile(pyfile) + if server in servers: + self.logDebug("Logging on to %s" % server) + self.req.addAuth(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)")) + else: + self.fail(e) else: - raise - + break + else: + self.fail(_("No file downloaded")) #@TODO: Move to hoster class (check if self.lastDownload) in 0.4.10 else: - self.fail(_("No Plugin matched and not a downloadable url")) + self.fail(_("No plugin matched")) def downloadFile(self, pyfile): @@ -78,31 +87,37 @@ class BasePlugin(Hoster): if 'location' in header: self.logDebug("Location: " + header['location']) + base = re.match(r'https?://[^/]+', url).group(0) + if header['location'].startswith("http"): url = header['location'] + elif header['location'].startswith("/"): url = base + unquote(header['location']) + else: url = '%s/%s' % (base, unquote(header['location'])) else: break - name = html_unescape(unquote(urlparse(url).path.split("/")[-1])) - if 'content-disposition' in header: self.logDebug("Content-Disposition: " + header['content-disposition']) + m = re.search("filename(?P=|\*=(?P.+)'')(?P.*)", header['content-disposition']) if m: disp = m.groupdict() + self.logDebug(disp) + if not disp['enc']: disp['enc'] = 'utf-8' + name = remove_chars(disp['name'], "\"';").strip() name = unicode(unquote(name), disp['enc']) - if not name: - name = url - pyfile.name = name - self.logDebug("Filename: %s" % pyfile.name) + pyfile.name = name + + self.logDebug("Filename changed to: " + name) + self.download(url, disposition=True) -- cgit v1.2.3 From 6b4527b5603b84dd26e40d85264c4d35778ad275 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 23 Nov 2014 02:08:51 +0100 Subject: [ZShareNet] Dead hoster --- module/plugins/hoster/ZShareNet.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 module/plugins/hoster/ZShareNet.py (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/ZShareNet.py b/module/plugins/hoster/ZShareNet.py new file mode 100644 index 000000000..dc96facbe --- /dev/null +++ b/module/plugins/hoster/ZShareNet.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class ZShareNet(DeadHoster): + __name__ = "ZShareNet" + __type__ = "hoster" + __version__ = "0.21" + + __pattern__ = r'https?://(?:ww[2w]\.)?zshares?\.net/.+' + + __description__ = """ZShare.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("espes", None), + ("Cptn Sandwich", None)] + + +getInfo = create_getInfo(ZShareNet) -- cgit v1.2.3 From 2ca8cc959a587992dc389d6baf71dd3e4f66df1c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 23 Nov 2014 04:41:17 +0100 Subject: Fix some URL_REPLACEMENTS --- module/plugins/hoster/DataportCz.py | 4 +--- module/plugins/hoster/DepositfilesCom.py | 12 ++++++------ module/plugins/hoster/NowVideoAt.py | 4 ++-- module/plugins/hoster/TurbobitNet.py | 4 ++-- module/plugins/hoster/VeohCom.py | 6 +++--- module/plugins/hoster/VimeoCom.py | 8 ++++---- 6 files changed, 18 insertions(+), 20 deletions(-) (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/DataportCz.py b/module/plugins/hoster/DataportCz.py index 6bea4afac..b9e6fd370 100644 --- a/module/plugins/hoster/DataportCz.py +++ b/module/plugins/hoster/DataportCz.py @@ -6,7 +6,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class DataportCz(SimpleHoster): __name__ = "DataportCz" __type__ = "hoster" - __version__ = "0.39" + __version__ = "0.40" __pattern__ = r'http://(?:www\.)?dataport\.cz/file/(.*)' @@ -19,8 +19,6 @@ class DataportCz(SimpleHoster): SIZE_PATTERN = r'Velikost\s*(?P[^<]+)' OFFLINE_PATTERN = r'

Soubor nebyl nalezen

' - URL_REPLACEMENTS = [(__pattern__, r'http://www.dataport.cz/file/\1')] - CAPTCHA_PATTERN = r'
\s*(\d+)
' diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py index d414e7021..6588a3b37 100644 --- a/module/plugins/hoster/DepositfilesCom.py +++ b/module/plugins/hoster/DepositfilesCom.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class DepositfilesCom(SimpleHoster): __name__ = "DepositfilesCom" __type__ = "hoster" - __version__ = "0.50" + __version__ = "0.51" __pattern__ = r'https?://(?:www\.)?(depositfiles\.com|dfiles\.(eu|ru))(/\w{1,3})?/files/(?P\w+)' @@ -22,18 +22,18 @@ class DepositfilesCom(SimpleHoster): ("Walter Purcaro", "vuolter@gmail.com")] - NAME_PATTERN = r'