diff options
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/crypter/DontKnowMe.py | 21 | ||||
-rw-r--r-- | module/plugins/hooks/LinkdecrypterCom.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/YibaishiwuCom.py | 62 | ||||
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 70 |
4 files changed, 124 insertions, 33 deletions
diff --git a/module/plugins/crypter/DontKnowMe.py b/module/plugins/crypter/DontKnowMe.py new file mode 100644 index 000000000..dfa72df47 --- /dev/null +++ b/module/plugins/crypter/DontKnowMe.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +import re +import urllib + +from module.plugins.Crypter import Crypter + +class DontKnowMe(Crypter): + __name__ = "DontKnowMe" + __type__ = "crypter" + __pattern__ = r"http://dontknow.me/at/\?.+$" + __version__ = "0.1" + __description__ = """DontKnowMe""" + __author_name__ = ("selaux") + __author_mail__ = ("") + + LINK_PATTERN = r"http://dontknow.me/at/\?(.+)$" + + def decrypt(self, pyfile): + link = re.findall(self.LINK_PATTERN, self.pyfile.url)[0] + self.core.files.addLinks([ urllib.unquote(link) ], self.pyfile.package().id) diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index 5acdbddcb..90a42150b 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -24,7 +24,7 @@ from module.utils import remove_chars class LinkdecrypterCom(Hook): __name__ = "LinkdecrypterCom" - __version__ = "0.1" + __version__ = "0.11" __description__ = """linkdecrypter.com - regexp loader""" __config__ = [ ("activated", "bool", "Activated" , "True") ] __author_name__ = ("zoidberg") @@ -43,7 +43,7 @@ class LinkdecrypterCom(Hook): self.logError(_("Crypter list is empty")) return - regexp = r"http://[\w.]*?(%s).*" % "|".join(online) + regexp = r"http://(\w\.)*(%s).*" % "|".join(online) dict = self.core.pluginManager.crypterPlugins[self.__name__] dict["pattern"] = regexp diff --git a/module/plugins/hoster/YibaishiwuCom.py b/module/plugins/hoster/YibaishiwuCom.py new file mode 100644 index 000000000..be4742715 --- /dev/null +++ b/module/plugins/hoster/YibaishiwuCom.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + @author: zoidberg +""" + +import re +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.common.json_layer import json_loads + +class YibaishiwuCom(SimpleHoster): + __name__ = "YibaishiwuCom" + __type__ = "hoster" + __pattern__ = r"http://(?:www\.)?(?:u\.)?115.com/file/(?P<ID>\w+)" + __version__ = "0.1" + __description__ = """115.com""" + __author_name__ = ("zoidberg") + + FILE_NAME_PATTERN = r"file_name: '(?P<N>[^']+)'" + FILE_SIZE_PATTERN = r"file_size: '(?P<S>[^']+)'" + FILE_OFFLINE_PATTERN = ur'<h3><i style="color:red;">哎呀!提取码不存在!不妨搜搜看吧!</i></h3>' + + AJAX_GUEST_URL_PATTERN = r'url: "(/\?ct=pickcode[^"]+)"' + AJAX_FREEUSER_URL_PATTERN = r'url: "(/\?ct=download&ac=get^"]+)"' + + def handleFree(self): + url = False + if self.account: + found = re.search(self.AJAX_FREEUSER_URL_PATTERN, self.html) + if found: + url = found.group(1) + self.logDebug('FREEUSER URL: ' + url) + if not url: + found = re.search(self.AJAX_GUEST_URL_PATTERN, self.html) + if not found: self.parseError("AJAX URL") + url = found.group(1) + self.logDebug('GUEST URL: ' + url) + + response = json_loads(self.load("http://115.com" + url, decode = False)) + for mirror in response['data']: + try: + url = mirror['url'].replace('\\','') + self.logDebug("Trying URL: " + url) + header = self.download(url) + break + except: + continue + else: self.fail('No working link found') + +getInfo = create_getInfo(YibaishiwuCom)
\ No newline at end of file diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 69909a8a1..0aab2334c 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -35,38 +35,44 @@ def parseHtmlTagAttrValue(attr_name, tag): m = re.search(r"%s\s*=\s*([\"']?)((?<=\")[^\"]+|(?<=')[^']+|[^\s\"'][^>\s]+)\1" % attr_name, tag) return m.group(2) if m else '' -def parseFileInfo(self, url = '', html = '', infomode = False): - if not html and hasattr(self, "html"): html = self.html - +def parseFileInfo(self, url = '', html = '', infomode = False): info = {"name" : url, "size" : 0, "status" : 3} - online = False if hasattr(self, "req") and self.req.http.code == '404': info['status'] = 1 - elif hasattr(self, "FILE_OFFLINE_PATTERN") and re.search(self.FILE_OFFLINE_PATTERN, html): - # File offline - info['status'] = 1 else: - for pattern in ("FILE_INFO_PATTERN", "FILE_NAME_PATTERN", "FILE_SIZE_PATTERN"): - try: - info = dict(info, **re.search(getattr(self, pattern), html).groupdict()) - online = True - except AttributeError: - continue - - if online: - # File online, return name and size - info['status'] = 2 - if 'N' in info: - info['name'] = reSub(info['N'], self.FILE_NAME_REPLACEMENTS) - if 'S' in info: - size = reSub(info['S'] + info['U'] if 'U' in info else info['S'], self.FILE_SIZE_REPLACEMENTS) - info['size'] = parseFileSize(size) - elif isinstance(info['size'], (str, unicode)): - if 'units' in info: info['size'] += info['units'] - info['size'] = parseFileSize(info['size']) + if not html and hasattr(self, "html"): html = self.html + if isinstance(self.SH_BROKEN_ENCODING, (str, unicode)): + html = unicode(html, self.SH_BROKEN_ENCODING) + if hasattr(self, "html"): self.html = html + + if hasattr(self, "FILE_OFFLINE_PATTERN") and re.search(self.FILE_OFFLINE_PATTERN, html): + # File offline + info['status'] = 1 + else: + online = False + for pattern in ("FILE_INFO_PATTERN", "FILE_NAME_PATTERN", "FILE_SIZE_PATTERN"): + try: + info = dict(info, **re.search(getattr(self, pattern), html).groupdict()) + online = True + except AttributeError: + continue + + if online: + # File online, return name and size + info['status'] = 2 + if 'N' in info: + info['name'] = reSub(info['N'], self.FILE_NAME_REPLACEMENTS) + if 'S' in info: + size = reSub(info['S'] + info['U'] if 'U' in info else info['S'], self.FILE_SIZE_REPLACEMENTS) + info['size'] = parseFileSize(size) + elif isinstance(info['size'], (str, unicode)): + if 'units' in info: info['size'] += info['units'] + info['size'] = parseFileSize(info['size']) if infomode: + if hasattr(self, "pyfile"): + info = dict(info, **re.match(self.__pattern__, self.pyfile.url).groupdict()) return info else: return info['name'], info['size'], info['status'], url @@ -75,7 +81,7 @@ def create_getInfo(plugin): def getInfo(urls): for url in urls: file_info = parseFileInfo(plugin, url, getURL(reSub(url, plugin.FILE_URL_REPLACEMENTS), \ - decode = False if plugin.HTML_BROKEN_ENCODING else True)) + decode = not plugin.SH_BROKEN_ENCODING)) yield file_info return getInfo @@ -91,7 +97,7 @@ class PluginParseError(Exception): class SimpleHoster(Hoster): __name__ = "SimpleHoster" - __version__ = "0.17" + __version__ = "0.18" __pattern__ = None __type__ = "hoster" __description__ = """Base hoster plugin""" @@ -110,16 +116,18 @@ class SimpleHoster(Hoster): FILE_NAME_REPLACEMENTS = [("&#?\w+;", fixup)] FILE_URL_REPLACEMENTS = [] - HTML_BROKEN_ENCODING = False + SH_BROKEN_ENCODING = False # Set to True or encoding name if encoding in http header is not correct + SH_COOKIES = True + SH_CHECK_TRAFFIC = False def setup(self): - self.resumeDownload = self.multiDL = True if self.account else False + self.resumeDownload = self.multiDL = True if self.premium else False def process(self, pyfile): pyfile.url = reSub(pyfile.url, self.FILE_URL_REPLACEMENTS) - self.html = self.load(pyfile.url, decode = False if self.HTML_BROKEN_ENCODING else True) + self.html = self.load(pyfile.url, decode = not self.SH_BROKEN_ENCODING, cookies = self.SH_COOKIES) self.file_info = self.getFileInfo() - if self.premium: + if self.premium and (not self.SH_CHECK_TRAFFIC or self.checkTrafficLeft()): self.handlePremium() else: self.handleFree() |