From 339b2e07d78b15ca014ee12f1501cdb235d9b064 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 18 May 2015 11:50:43 +0200 Subject: [SimpleHoster] Fix create_getInfo --- module/plugins/crypter/LinkCryptWs.py | 6 +----- module/plugins/hooks/UserAgentSwitcher.py | 8 ++++---- module/plugins/hoster/ShareonlineBiz.py | 8 +++----- module/plugins/hoster/UploadedTo.py | 4 ++-- module/plugins/internal/DeadCrypter.py | 6 +++--- module/plugins/internal/DeadHoster.py | 6 +++--- module/plugins/internal/SimpleHoster.py | 30 +++++++++--------------------- 7 files changed, 25 insertions(+), 43 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/crypter/LinkCryptWs.py b/module/plugins/crypter/LinkCryptWs.py index d3e75aad4..5c65e726d 100644 --- a/module/plugins/crypter/LinkCryptWs.py +++ b/module/plugins/crypter/LinkCryptWs.py @@ -91,7 +91,7 @@ class LinkCryptWs(Crypter): def isOnline(self): if "Linkcrypt.ws // Error 404" in self.html: - self.logDebug("folder doesen't exist anymore") + self.logDebug("Folder doesn't exist anymore") return False else: return True @@ -197,8 +197,6 @@ class LinkCryptWs(Crypter): for idx, weblink_id in enumerate(ids): try: - self.logDebug("Decrypting Web link %d, %s" % (idx + 1, weblink_id)) - res = self.load("http://linkcrypt.ws/out.html", post = {'file':weblink_id}) indexs = res.find("window.location =") + 19 @@ -206,8 +204,6 @@ class LinkCryptWs(Crypter): link2 = res[indexs:indexe] - self.logDebug(link2) - link2 = html_unescape(link2) package_links.append(link2) diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 0b36e38ec..6915fc0f4 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -15,10 +15,10 @@ class UserAgentSwitcher(Hook): __type__ = "hook" __version__ = "0.04" - __config__ = [("activated", "bool", "Activated" , True ), - ("uaf" , "file", "Random user-agent by file" , "" ), - ("uar" , "bool", "Random user-agent" , False ), - ("uas" , "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0")] + __config__ = [("activated", "bool", "Activated" , True ), + ("uaf" , "file", "Random user-agent by file", "" ), + ("uar" , "bool", "Random user-agent" , False ), + ("uas" , "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")] __description__ = """Custom user-agent""" __license__ = "GPLv3" diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 505222fce..9d0cb631b 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -36,15 +36,13 @@ class ShareonlineBiz(SimpleHoster): @classmethod - def getInfo(cls, url="", html=""): - info = {'name': urlparse.urlparse(urllib.unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': url} + def apiInfo(cls, url): + info = super(ShareonlineBiz, cls).apiInfo(url) if url: - info['pattern'] = re.match(cls.__pattern__, url).groupdict() - field = getURL("http://api.share-online.biz/linkcheck.php", get={'md5': "1"}, - post={'links': info['pattern']['ID']}, + post={'links': re.match(cls.__pattern__, url).group("ID")}, decode=True).split(";") if field[1] == "OK": diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 75710ea8b..669694b22 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class UploadedTo(SimpleHoster): __name__ = "UploadedTo" __type__ = "hoster" - __version__ = "0.87" + __version__ = "0.88" __pattern__ = r'https?://(?:www\.)?(uploaded\.(to|net)|ul\.to)(/file/|/?\?id=|.*?&id=|/)(?P\w+)' __config__ = [("use_premium", "bool", "Use premium account if available", True)] @@ -36,7 +36,7 @@ class UploadedTo(SimpleHoster): @classmethod - def apiInfo(cls, url="", get={}, post={}): + def apiInfo(cls, url): info = super(UploadedTo, cls).apiInfo(url) for _i in xrange(5): diff --git a/module/plugins/internal/DeadCrypter.py b/module/plugins/internal/DeadCrypter.py index 866d177cf..c93447164 100644 --- a/module/plugins/internal/DeadCrypter.py +++ b/module/plugins/internal/DeadCrypter.py @@ -7,7 +7,7 @@ from module.plugins.Crypter import Crypter as _Crypter class DeadCrypter(_Crypter): __name__ = "DeadCrypter" __type__ = "crypter" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = r'^unmatchable$' @@ -17,8 +17,8 @@ class DeadCrypter(_Crypter): @classmethod - def apiInfo(cls, url="", get={}, post={}): - api = super(DeadCrypter, self).apiInfo(url, get, post) + def apiInfo(cls, url): + api = super(DeadCrypter, cls).apiInfo(url) api['status'] = 1 return api diff --git a/module/plugins/internal/DeadHoster.py b/module/plugins/internal/DeadHoster.py index a6ad92607..f159ae5fa 100644 --- a/module/plugins/internal/DeadHoster.py +++ b/module/plugins/internal/DeadHoster.py @@ -7,7 +7,7 @@ from module.plugins.Hoster import Hoster as _Hoster class DeadHoster(_Hoster): __name__ = "DeadHoster" __type__ = "hoster" - __version__ = "0.14" + __version__ = "0.15" __pattern__ = r'^unmatchable$' @@ -17,8 +17,8 @@ class DeadHoster(_Hoster): @classmethod - def apiInfo(cls, url="", get={}, post={}): - api = super(DeadHoster, self).apiInfo(url, get, post) + def apiInfo(cls, url): + api = super(DeadHoster, cls).apiInfo(url) api['status'] = 1 return api diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 9303bcf2e..aae3bac8c 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -100,7 +100,7 @@ def parseHtmlForm(attr_str, html, input_names={}): return {}, None #: no matching form found -#: Deprecated +#@TODO: Remove in 0.4.10 def parseFileInfo(plugin, url="", html=""): if hasattr(plugin, "getInfo"): info = plugin.getInfo(url, html) @@ -119,19 +119,14 @@ def parseFileInfo(plugin, url="", html=""): #@TODO: Remove in 0.4.10 -#@NOTE: Every plugin must have own parseInfos classmethod to work with 0.4.10 def create_getInfo(plugin): + def getInfo(urls): + for url in urls: + if hasattr(plugin, "URL_REPLACEMENTS"): + url = replace_patterns(url, plugin.URL_REPLACEMENTS) + yield parseFileInfo(plugin, url) - def generator(list): - for x in list: - yield x - - if hasattr(plugin, "parseInfos"): - fn = lambda urls: generator((info['name'], info['size'], info['status'], info['url']) for info in plugin.parseInfos(urls)) - else: - fn = lambda urls: generator(parseFileInfo(url) for url in urls) - - return fn + return getInfo def timestamp(): @@ -244,7 +239,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.44" + __version__ = "1.45" __pattern__ = r'^unmatchable$' __config__ = [("use_premium", "bool", "Use premium account if available" , True), @@ -325,14 +320,7 @@ class SimpleHoster(Hoster): @classmethod - def parseInfos(cls, urls): #@TODO: Built-in in 0.4.10 core (remove from plugins) - for url in urls: - url = replace_patterns(url, cls.URL_REPLACEMENTS) - yield cls.getInfo(url) - - - @classmethod - def apiInfo(cls, url="", get={}, post={}): + def apiInfo(cls, url): url = urllib.unquote(url) url_p = urlparse.urlparse(url) return {'name' : (url_p.path.split('/')[-1] -- cgit v1.2.3