diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2011-10-05 12:12:37 +0200 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2011-10-05 12:12:37 +0200 |
commit | 9c0c7d97b958c2ab281dbbeb448e17a20e6acc60 (patch) | |
tree | c21441d42e5846e345cce2c12056438cc6e01e7f | |
parent | hotfile premium fix (diff) | |
download | pyload-9c0c7d97b958c2ab281dbbeb448e17a20e6acc60.tar.xz |
hoster plugin fixes; new plugins: mediafire, sendspace
-rw-r--r-- | module/plugins/hoster/MediafireCom.py | 130 | ||||
-rw-r--r-- | module/plugins/hoster/MultishareCz.py | 8 | ||||
-rw-r--r-- | module/plugins/hoster/SendspaceCom.py | 108 | ||||
-rw-r--r-- | module/plugins/hoster/UloziskoSk.py | 22 |
4 files changed, 260 insertions, 8 deletions
diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py new file mode 100644 index 000000000..f7c122f40 --- /dev/null +++ b/module/plugins/hoster/MediafireCom.py @@ -0,0 +1,130 @@ +# -*- 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.common.JsEngine import JsEngine +from module.plugins.Hoster import Hoster +from module.network.RequestFactory import getURL + +def getInfo(urls): + result = [] + + for url in urls: + html = getURL(url, decode=True) + if re.search(MediafireCom.FILE_OFFLINE_PATTERN, html): + # File offline + result.append((url, 0, 1, url)) + else: + # Get file info + name, size = url, 0 + + found = re.search(MediafireCom.FILE_SIZE_PATTERN, html) + if found is not None: + size, units = found.groups() + size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units] + + found = re.search(MediafireCom.FILE_NAME_PATTERN, html) + if found is not None: + name = found.group(1) + + if found or size > 0: + result.append((name, size, 2, url)) + yield result + +class MediafireCom(Hoster): + __name__ = "MediafireCom" + __type__ = "hoster" + __pattern__ = r"http://(?:\w*\.)*mediafire\.com/.*" + __version__ = "0.2" + __description__ = """Mediafire.com plugin - free only""" + __author_name__ = ("zoidberg") + + PAGE1_FUNCTION_PATTERN = r"function %s\(qk,pk1\)\{if[^']*'loadingicon'\);[^;]*; (.*?)eval" + PAGE1_KEY_PATTERN = ";break;}\s*(\w+='';\w+=unescape.*?)eval\(" + PAGE1_RESULT_PATTERN = r"(\w+)\('(?P<qk>[^']+)','(?P<pk1>[^']+)'\)" + PAGE1_DIV_PATTERN = r'getElementById\("(\w{32})"\)' + PAGE1_PKR_PATTERN = r"pKr='([^']+)';" + + PAGE2_VARS_PATTERN = r'<script language="Javascript"><!--\s*(var.*?unescape.*?)eval\(' + PAGE2_DZ_PATTERN = r'break;case 15:(.*)</script>' + PAGE2_LINK_PATTERN = r"(?:if.*</a>\')?(?:eval\(\")?(.*?)eval\(" + FINAL_LINK_PATTERN = r'parent.document.getElementById\(\'(\w{32})\'\)\).*?"(http://download[^"]+)" \+(\w+)\+ "([^"]+)">' + + FILE_NAME_PATTERN = r'<META NAME="description" CONTENT="([^"]+)"/>' + FILE_SIZE_PATTERN = r'<div style="font-size:14px;padding-top:12px;color:#777;">\(([0-9.]+) (kB|MB|GB)\)</div>' + FILE_OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>' + + def process(self, pyfile): + self.html = self.load(pyfile.url, decode = True, cookies = True) + + try: + pyfile.name = re.search(self.FILE_NAME_PATTERN, self.html).group(1) + found = re.search(self.FILE_SIZE_PATTERN, self.html) + pyfile.size = float(found.group(1)) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[found.group(2)] + except Exception, e: + self.logError(e) + self.retry(3, 0, "Parse error - file info") + + self.handleFree(pyfile) + + def handleFree(self, pyfile): + js = JsEngine() + + found = re.search(self.PAGE1_KEY_PATTERN, self.html) + if found: + result = js.eval(found.group(1)) + found = re.search(self.PAGE1_RESULT_PATTERN, result) + else: + self.fail("Parse error - javascript") + + param_dict = found.groupdict() + param_dict['r'] = re.search(self.PAGE1_PKR_PATTERN, self.html).group(1) + self.logDebug(param_dict) + key_func = found.group(1) + self.logDebug("KEY_FUNC: %s" % key_func) + + found = re.search(self.PAGE1_FUNCTION_PATTERN % key_func, self.html) + result = js.eval(found.group(1)) + key_div = found = re.search(self.PAGE1_DIV_PATTERN, result).group(1) + self.logDebug("KEY_DIV: %s" % key_div) + + self.html = self.load("http://www.mediafire.com/dynamic/download.php", get = param_dict, cookies = True) + result = js.eval(re.search(self.PAGE2_VARS_PATTERN, self.html).group(1)) + var_list = dict(re.findall("([^=]+)='([^']+)';", result)) + + page2_dz = re.search(self.PAGE2_DZ_PATTERN, self.html, re.DOTALL).group(1) + + final_link = None + for link_enc in re.finditer(self.PAGE2_LINK_PATTERN, page2_dz): + #self.logDebug("LINK_ENC: %s..." % link_enc.group(1)[:20]) + try: + link_dec = js.eval(link_enc.group(1).replace(r"\'",r"'")) + except: + self.logError("Unable to decrypt link %s" % link_enc.group(1)[:20]) + self.logDebug(link_enc.group(1).replace(r"\'",r"'")) + continue + + found = re.search(self.FINAL_LINK_PATTERN, link_dec) + if found and found.group(1) == key_div: + final_link = found.group(2) + var_list[found.group(3)] + found.group(4) + break; + else: + self.fail("Final link not found") + + self.logDebug("FINAL LINK: %s" % final_link) + self.download(final_link, cookies=True)
\ No newline at end of file diff --git a/module/plugins/hoster/MultishareCz.py b/module/plugins/hoster/MultishareCz.py index 488fdcbc4..d8dfeaed9 100644 --- a/module/plugins/hoster/MultishareCz.py +++ b/module/plugins/hoster/MultishareCz.py @@ -51,13 +51,13 @@ class MultishareCz(Hoster): __name__ = "MultishareCz" __type__ = "hoster" __pattern__ = r"http://(\w*\.)?multishare.cz/stahnout/.*" - __version__ = "0.2" + __version__ = "0.3" __description__ = """MultiShare.cz""" __author_name__ = ("zoidberg") FILE_ID_PATTERN = r'/stahnout/(\d+)/' - FILE_INFO_PATTERN = r'<ul class="no-padding"><li>N�zev: <strong>([^<]+)</strong></li><li>Velikost: <strong>([^&]+) ([^<]+)</strong>' - OFFLINE_PATTERN = r'<h1>St�hnout soubor</h1><p><strong>Po.adovan� soubor neexistuje.</strong></p>' + FILE_INFO_PATTERN = ur'<ul class="no-padding"><li>Název: <strong>([^<]+)</strong></li><li>Velikost: <strong>([^&]+) ([^<]+)</strong>' + OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>' def setup(self): self.multiDL = False @@ -80,4 +80,4 @@ class MultishareCz(Hoster): self.download("http://www.multishare.cz/html/download_free.php", get={ "ID": file_id - }) + })
\ No newline at end of file diff --git a/module/plugins/hoster/SendspaceCom.py b/module/plugins/hoster/SendspaceCom.py new file mode 100644 index 000000000..1d65945c7 --- /dev/null +++ b/module/plugins/hoster/SendspaceCom.py @@ -0,0 +1,108 @@ +# -*- 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.Hoster import Hoster +from module.network.RequestFactory import getURL + +def getInfo(urls): + result = [] + + for url in urls: + html = getURL(url, decode=True) + if re.search(SendspaceCom.FILE_OFFLINE_PATTERN, html): + # File offline + result.append((url, 0, 1, url)) + else: + # Get file info + name, size = url, 0 + + found = re.search(SendspaceCom.FILE_SIZE_PATTERN, html) + if found is not None: + size, units = found.groups() + size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] + + found = re.search(SendspaceCom.FILE_NAME_PATTERN, html) + if found is not None: + name = found.group(1) + + if found or size > 0: + result.append((name, size, 2, url)) + yield result + + +class SendspaceCom(Hoster): + __name__ = "SendspaceCom" + __type__ = "hoster" + __pattern__ = r"http://(www\.)?sendspace.com/file/.*" + __version__ = "0.1" + __description__ = """sendspace.com plugin - free only""" + __author_name__ = ("zoidberg") + + DOWNLOAD_URL_PATTERN = r'<a id="download_button" href="([^"]+)"' + FILE_NAME_PATTERN = r'<h2 class="bgray">\s*<(?:b|strong)>([^<]+)</' + FILE_SIZE_PATTERN = r'<div class="file_description reverse margin_center">\s*<b>File Size:</b>\s*([0-9.]+)(KB|MB|GB)\s*</div>' + FILE_OFFLINE_PATTERN = r'<div class="msg error" style="cursor: default">Sorry, the file you requested is not available.</div>' + CAPTCHA_PATTERN = r'<td><img src="(/captchas/captcha.php?captcha=([^"]+))"></td>' + USER_CAPTCHA_PATTERN = r'<td><img src="/captchas/captcha.php?user=([^"]+))"></td>' + + def setup(self): + self.multiDL = False + + def process(self, pyfile): + self.html = self.load(pyfile.url, decode=True) + + if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: + self.offline() + + found = re.search(self.FILE_NAME_PATTERN, self.html) + if found is None: self.fail("Parse error (file name)") + pyfile.name = found.group(1) + + found = re.search(self.FILE_SIZE_PATTERN, self.html) + if found is None: self.fail("Parse error (file size)") + pyfile.size = float(found.group(1)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(2)] + + params = {} + for i in range(3): + found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) + if found: + if params.has_key('captcha_hash'): self.correctCaptcha() + download_url = found.group(1) + break + + found = re.search(self.CAPTCHA_PATTERN, self.html) + if found: + if params.has_key('captcha_hash'): self.invalidCaptcha() + captcha_url1 = "http://www.sendspace.com/" + found.group(1) + found = re.search(self.USER_CAPTCHA_PATTERN, self.html) + captcha_url2 = "http://www.sendspace.com/" + found.group(1) + params = {'captcha_hash' : found.group(2), + 'captcha_submit': 'Verify', + 'captcha_answer': self.decryptCaptcha(captcha_url1) + " " + self.decryptCaptcha(captcha_url2) + } + else: + params = {'download': "Regular Download"} + + self.logDebug(params) + self.html = self.load(pyfile.url, post = params) + else: + self.fail("Download link not found") + + self.logDebug("Download URL: %s" % download_url) + self.download(download_url) diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index b8ec0df55..e439a0f87 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -30,10 +30,19 @@ def getInfo(urls): result.append((url, 0, 1, url)) else: # Get file info + name, size = url, 0 + + found = re.search(UloziskoSk.FILE_SIZE_PATTERN, html) + if found is not None: + size, units = found.groups() + size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] + found = re.search(UloziskoSk.FILE_NAME_PATTERN, html) if found is not None: name = found.group(1) - result.append((name, 0, 2, url)) + + if found or size > 0: + result.append((name, size, 2, url)) yield result @@ -41,15 +50,16 @@ class UloziskoSk(Hoster): __name__ = "UloziskoSk" __type__ = "hoster" __pattern__ = r"http://(\w*\.)?ulozisko.sk/.*" - __version__ = "0.1" + __version__ = "0.2" __description__ = """Ulozisko.sk""" __author_name__ = ("zoidberg") URL_PATTERN = r'<form name = "formular" action = "([^"]+)" method = "post">' ID_PATTERN = r'<input type = "hidden" name = "id" value = "([^"]+)" />' FILE_NAME_PATTERN = r'<input type = "hidden" name = "name" value = "([^"]+)" />' + FILE_SIZE_PATTERN = ur'Veľkosť súboru: <strong>([0-9.]+) (KB|MB|GB)</strong><br />' CAPTCHA_PATTERN = r'<img src="(/obrazky/obrazky.php\?fid=[^"]+)" alt="" />' - FILE_OFFLINE_PATTERN = r'<span class = "red">Zadan� s�bor neexistuje z jedn�ho z nasleduj�cich d�vodov:</span>' + FILE_OFFLINE_PATTERN = ur'<span class = "red">Zadaný súbor neexistuje z jedného z nasledujúcich dôvodov:</span>' def setup(self): self.multiDL = False @@ -69,6 +79,11 @@ class UloziskoSk(Hoster): if found is None: self.fail("Parse error (FILENAME)") pyfile.name = found.group(1) + + found = re.search(self.FILE_SIZE_PATTERN, self.html) + if found is not None: + size, units = found.groups() + pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] found = re.search(self.ID_PATTERN, self.html) if found is None: @@ -92,4 +107,3 @@ class UloziskoSk(Hoster): "name": pyfile.name, "but": "++++STIAHNI+S%DABOR++++" }) -
\ No newline at end of file |