diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-01-10 16:01:38 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-01-10 16:01:38 +0100 |
commit | 502c1437e838282aa56a286bb3751382c3aaf65e (patch) | |
tree | 088f89ac569dc928e8c478bf4163a2595b6b0510 /module/plugins | |
parent | [MultiHoster] Fix filename recognition (diff) | |
download | pyload-502c1437e838282aa56a286bb3751382c3aaf65e.tar.xz |
Improve getInfo
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/hoster/BasePlugin.py | 10 | ||||
-rw-r--r-- | module/plugins/internal/DeadCrypter.py | 6 | ||||
-rw-r--r-- | module/plugins/internal/DeadHoster.py | 6 | ||||
-rw-r--r-- | module/plugins/internal/MultiHook.py | 10 | ||||
-rw-r--r-- | module/plugins/internal/SimpleCrypter.py | 15 | ||||
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 40 | ||||
-rw-r--r-- | module/plugins/internal/XFSAccount.py | 2 |
7 files changed, 53 insertions, 36 deletions
diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index c2825493b..6d3132e65 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -13,7 +13,7 @@ from module.plugins.Hoster import Hoster class BasePlugin(Hoster): __name__ = "BasePlugin" __type__ = "hoster" - __version__ = "0.29" + __version__ = "0.30" __pattern__ = r'^unmatchable$' @@ -25,7 +25,13 @@ class BasePlugin(Hoster): @classmethod def getInfo(cls, url="", html=""): #@TODO: Move to hoster class in 0.4.10 - return {'name': urlparse(unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': unquote(url) or ""} + url = unquote(url) + return {'name' : (urlparse(url).path.split('/')[-1] + or urlparse(url).query.split('=', 1)[::-1][0].split('&', 1)[0] + or _("Unknown")), + 'size' : 0, + 'status': 3 if url else 8, + 'url' : url} def setup(self): diff --git a/module/plugins/internal/DeadCrypter.py b/module/plugins/internal/DeadCrypter.py index 07c5c3881..0fa23eef3 100644 --- a/module/plugins/internal/DeadCrypter.py +++ b/module/plugins/internal/DeadCrypter.py @@ -20,8 +20,10 @@ class DeadCrypter(_Crypter): @classmethod - def getInfo(cls, url="", html=""): - return {'name': urlparse(unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 1, 'url': url} + def apiInfo(cls, url="", get={}, post={}): + api = super(DeadCrypter, self).apiInfo(url, get, post) + api['status'] = 1 + return api def setup(self): diff --git a/module/plugins/internal/DeadHoster.py b/module/plugins/internal/DeadHoster.py index 6f3252f70..cc7adf4df 100644 --- a/module/plugins/internal/DeadHoster.py +++ b/module/plugins/internal/DeadHoster.py @@ -20,8 +20,10 @@ class DeadHoster(_Hoster): @classmethod - def getInfo(cls, url="", html=""): - return {'name': urlparse(unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 1, 'url': url} + def apiInfo(cls, url="", get={}, post={}): + api = super(DeadHoster, self).apiInfo(url, get, post) + api['status'] = 1 + return api def setup(self): diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py index bb132252f..4408ebf0e 100644 --- a/module/plugins/internal/MultiHook.py +++ b/module/plugins/internal/MultiHook.py @@ -9,7 +9,7 @@ from module.utils import decode, remove_chars class MultiHook(Hook): __name__ = "MultiHook" __type__ = "hook" - __version__ = "0.32" + __version__ = "0.33" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -27,10 +27,10 @@ class MultiHook(Hook): MIN_INTERVAL = 1 * 60 * 60 - DOMAIN_REPLACEMENTS = [(r'180upload.com' , "hundredeightyupload.com"), - (r'1fichier.com' , "onefichier.com" ), - (r'2shared.com' , "twoshared.com" ), - (r'4shared.com' , "fourshared.com" ), + DOMAIN_REPLACEMENTS = [(r'180upload\.com' , "hundredeightyupload.com"), + (r'1fichier\.com' , "onefichier.com" ), + (r'2shared\.com' , "twoshared.com" ), + (r'4shared\.com' , "fourshared.com" ), (r'bayfiles\.net' , "bayfiles.com" ), (r'cloudnator\.com' , "shragle.com" ), (r'dfiles\.eu' , "depositfiles.com" ), diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index c1571c679..43b1347fd 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -122,27 +122,28 @@ class SimpleCrypter(Crypter, SimpleHoster): def checkNameSize(self, getinfo=True): - if getinfo: + if not self.info or getinfo: self.logDebug("File info (BEFORE): %s" % self.info) self.info.update(self.getInfo(self.pyfile.url, self.html)) self.logDebug("File info (AFTER): %s" % self.info) try: - name = self.info['name'] url = self.info['url'] - + name = self.info['name'] if name and name != url: self.pyfile.name = name - else: - self.pyfile.name = self.info['name'] = urlparse(name).path.split('/')[-1] except Exception: pass - folder = self.info['folder'] = self.pyfile.name + try: + folder = self.info['folder'] = self.pyfile.name + + except Exception: + pass self.logDebug("File name: %s" % self.pyfile.name, - "File folder: %s" % folder) + "File folder: %s" % self.pyfile.name) def getLinks(self): diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 1a2961167..fb19b8725 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -183,7 +183,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.92" + __version__ = "0.93" __pattern__ = r'^unmatchable$' @@ -264,7 +264,7 @@ class SimpleHoster(Hoster): or urlparse(url).query.split('=', 1)[::-1][0].split('&', 1)[0] or _("Unknown")), 'size' : 0, - 'status': 3, + 'status': 3 if url else 8, 'url' : url} @@ -462,6 +462,10 @@ class SimpleHoster(Hoster): def checkErrors(self): + if not self.html: + self.logWarning(_("No html code to check")) + return + if hasattr(self, 'PREMIUM_ONLY_PATTERN') and self.premium and re.search(self.PREMIUM_ONLY_PATTERN, self.html): self.fail(_("Link require a premium account to be handled")) @@ -483,42 +487,44 @@ class SimpleHoster(Hoster): def checkStatus(self, getinfo=True): - if getinfo: + if not self.info or getinfo: self.logDebug("File info (BEFORE): %s" % self.info) self.info.update(self.getInfo(self.pyfile.url, self.html)) - if 'status' not in self.info: - return + try: + status = self.info['status'] - status = self.info['status'] + if status is 1: + self.offline() - if status is 1: - self.offline() + elif status is 6: + self.tempOffline() - elif status is 6: - self.tempOffline() + elif status is 8: + self.fail() - elif status is not 2: + finally: self.logDebug("File status: %s" % statusMap[status], "File info: %s" % self.info) def checkNameSize(self, getinfo=True): - if getinfo: + if not self.info or getinfo: self.logDebug("File info (BEFORE): %s" % self.info) self.info.update(self.getInfo(self.pyfile.url, self.html)) self.logDebug("File info (AFTER): %s" % self.info) try: - name = self.info['name'] - size = self.info['size'] url = self.info['url'] - + name = self.info['name'] if name and name != url: self.pyfile.name = name - else: - self.pyfile.name = name = self.info['name'] = urlparse(name).path.split('/')[-1] + except Exception: + pass + + try: + size = self.info['size'] if size > 0: self.pyfile.size = size diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py index 263d78ff8..a767a878f 100644 --- a/module/plugins/internal/XFSAccount.py +++ b/module/plugins/internal/XFSAccount.py @@ -143,7 +143,7 @@ class XFSAccount(Account): if isinstance(self.COOKIES, list): set_cookies(req.cj, self.COOKIES) - url = urljoin(self.HOSTER_URL, "login.html") + url = urljoin(self.HOSTER_URL, "login.html") html = req.load(url, decode=True) action, inputs = parseHtmlForm('name="FL"', html) |