diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2011-09-30 16:03:54 +0200 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2011-09-30 16:03:54 +0200 |
commit | 931ab695ec84be3bbf1137593c4333c184cabb5d (patch) | |
tree | 934c0552a62b58281a8b30219150b659873bd7d5 /module | |
parent | show warning only one time (diff) | |
download | pyload-931ab695ec84be3bbf1137593c4333c184cabb5d.tar.xz |
hoster plugins: add ifile.it, update share-rapid.com, ifolder.ru
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/hoster/IfileIt.py | 104 | ||||
-rw-r--r-- | module/plugins/hoster/IfolderRu.py | 26 | ||||
-rw-r--r-- | module/plugins/hoster/ShareRapidCom.py | 73 |
3 files changed, 176 insertions, 27 deletions
diff --git a/module/plugins/hoster/IfileIt.py b/module/plugins/hoster/IfileIt.py new file mode 100644 index 000000000..77961e51e --- /dev/null +++ b/module/plugins/hoster/IfileIt.py @@ -0,0 +1,104 @@ +# -*- 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 json import loads as json_loads +from module.common.JsEngine import JsEngine +from module.plugins.ReCaptcha import ReCaptcha +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(IfileIt.FILE_OFFLINE_PATTERN, html): + # File offline + result.append((url, 0, 1, url)) + else: + # Get file info + name, size = url, 0 + + found = re.search(IfileIt.FILE_INFO_PATTERN, html) + if found is not None: + name, size, units = found.groups() + size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units] + result.append((name, size, 2, url)) + yield result + +class IfileIt(Hoster): + __name__ = "IfileIt" + __type__ = "hoster" + __pattern__ = r"http://(?:\w*\.)*ifile\.it/.*" + __version__ = "0.2" + __description__ = """Ifile.it""" + __author_name__ = ("zoidberg") + + EVAL_PATTERN = r'(eval\(function\(p,a,c,k,e,d\).*)' + DEC_PATTERN = r"function requestBtn_clickEvent[^}]*url:\s*([^,]+)" + DOWNLOAD_LINK_PATTERN = r'</span> If it doesn\'t, <a target="_blank" href="([^"]+)">' + RECAPTCHA_KEY_PATTERN = r"var __recaptcha_public\s*=\s*'([^']+)';" + FILE_INFO_PATTERN = r'<span style="cursor: default;[^>]*>\s*(.*?)\s* \s*<strong>\s*([0-9.]+)\s*(kB|MB|GB)\s*</strong>\s*</span>' + FILE_OFFLINE_PATTERN = r'$\("#errorPnl"\)\.empty\(\)\.append\( "no such file" \);' + + def process(self, pyfile): + self.html = self.load(pyfile.url, cookies = True) + + found = re.search(self.FILE_INFO_PATTERN, self.html) + pyfile.name = found.group(1) + pyfile.size = pyfile.size = float(found.group(2)) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[found.group(3)] + + eval_string = re.search(self.EVAL_PATTERN, self.html).group(1) + dec_string = re.search(self.DEC_PATTERN, self.html).group(1) + recaptcha_key = re.search(self.RECAPTCHA_KEY_PATTERN, self.html).group(1) + + js = JsEngine() + json_url = js.eval(eval_string+";"+dec_string) + self.logDebug(json_url) + + json_response = json_loads(self.load(json_url, cookies = True)) + self.logDebug(json_response) + if json_response["captcha"]: + captcha_key = re.search(self.RECAPTCHA_KEY_PATTERN, self.html).group(1) + recaptcha = ReCaptcha(self) + + for i in range(5): + captcha_challenge, captcha_response = recaptcha.challenge(captcha_key) + + json_response = json_loads(self.load(json_url, post={ + "ctype": "recaptcha", + "recaptcha_challenge": captcha_challenge, + "recaptcha_response": captcha_response + })) + + self.logDebug(json_response) + if json_response["retry"]: + self.invalidCaptcha() + else: + self.correctCaptcha() + break + else: + self.fail("Incorrect captcha") + + # load twice + self.html = self.load(pyfile.url, cookies = True) + self.html = self.load(pyfile.url, cookies = True) + download_url = re.search(self.DOWNLOAD_LINK_PATTERN, self.html).group(1) + + self.download(download_url)
\ No newline at end of file diff --git a/module/plugins/hoster/IfolderRu.py b/module/plugins/hoster/IfolderRu.py index 8675dbdc4..063ebfbff 100644 --- a/module/plugins/hoster/IfolderRu.py +++ b/module/plugins/hoster/IfolderRu.py @@ -32,24 +32,27 @@ def getInfo(urls): result.append((url, 0, 1, url)) else: # Get file info - found = re.search(IfolderRu.FILE_INFO_PATTERN, html) + found = re.search(IfolderRu.FILE_NAME_PATTERN, html) if found is not None: name = found.group(1) - size = float(found.group(2)) * 1024 ** {u'Кб': 1, u'Мб': 2, u'Гб': 3}[found.group(3)] - result.append((name, size, 2, url)) + found = re.search(IfolderRu.FILE_SIZE_PATTERN, html) + if found is not None: + size = float(found.group(1)) * 1024 ** {u'Кб': 1, u'Мб': 2, u'Гб': 3}[found.group(2)] + result.append((name, size, 2, url)) yield result class IfolderRu(Hoster): __name__ = "IfolderRu" __type__ = "hoster" - __pattern__ = r"http://(?:\w*\.)?ifolder.ru/(\d+)/?" - __version__ = "0.2" + __pattern__ = r"http://(?:\w*\.)?ifolder.ru/(\d+).*" + __version__ = "0.3" __description__ = """ifolder.ru""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - FILE_INFO_PATTERN = ur'<div><span>Название:</span> <b>([^<]+)</b></div>\s*<div><span>Размер:</span> <b>([0-9.]+) ([^<]+)</b></div>' + FILE_NAME_PATTERN = ur'^\s*(?:<div><span>)?Название:(?:</span>)? <b>([^<]+)</b><(?:/div|br)>' + FILE_SIZE_PATTERN = ur'^\s*(?:<div><span>)?Размер:(?:</span>)? <b>([0-9.]+) ([^<]+)</b><(?:/div|br)>' SESSION_ID_PATTERN = r'<a href=(http://ints.ifolder.ru/ints/sponsor/\?bi=\d*&session=([^&]+)&u=[^>]+)>' FORM1_PATTERN = r'<form method=post name="form1" ID="Form1" style="margin-bottom:200px">(.*?)</form>' FORM_INPUT_PATTERN = r'<input[^>]* name="?([^" ]+)"? value="?([^" ]+)"?[^>]*>' @@ -64,13 +67,16 @@ class IfolderRu(Hoster): self.chunkLimit = 1 def process(self, pyfile): - self.html = self.load(pyfile.url, cookies=True, decode=True) + file_id = re.search(self.__pattern__, pyfile.url).group(1) + self.html = self.load("http://ifolder.ru/%s" % file_id, cookies=True, decode=True) if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() - found = re.search(self.FILE_INFO_PATTERN, self.html) + found = re.search(self.FILE_NAME_PATTERN, self.html) + if not found: self.fail("Parse error (File name)") pyfile.name = found.group(1) - pyfile.size = float(found.group(2)) * 1024 ** {u'Кб': 1, u'Мб': 2, u'Гб': 3}[found.group(3)] - file_id = re.search(self.__pattern__, pyfile.url).group(1) + found = re.search(self.FILE_SIZE_PATTERN, self.html) + if not found: self.fail("Parse error (File size)") + pyfile.size = float(found.group(1)) * 1024 ** {u'Кб': 1, u'Мб': 2, u'Гб': 3}[found.group(2)] url = "http://ints.ifolder.ru/ints/?ifolder.ru/%s?ints_code=" % file_id self.html = self.load(url, cookies=True, decode=True) diff --git a/module/plugins/hoster/ShareRapidCom.py b/module/plugins/hoster/ShareRapidCom.py index e7979d0a8..96962cffe 100644 --- a/module/plugins/hoster/ShareRapidCom.py +++ b/module/plugins/hoster/ShareRapidCom.py @@ -3,34 +3,73 @@ 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(ShareRapidCom.FILE_OFFLINE_PATTERN, html): + # File offline + result.append((url, 0, 1, url)) + else: + # Get file info + name, size = url, 0 + + found = re.search(ShareRapidCom.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(ShareRapidCom.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 ShareRapidCom(Hoster): __name__ = "ShareRapidCom" __type__ = "hoster" - __pattern__ = r"http://(?:www.)?(share-rapid)?(.com|.cz)/" - __version__ = "0.1" + __pattern__ = r"http://(?:www\.)?share-rapid\.(com|cz)/" + __version__ = "0.3" __description__ = """share-rapid Plugin""" - __author_name__ = ("MikyWoW") - __author_mail__ = ("MikyWoW@seznam.cz") + __author_name__ = ("MikyWoW", "zoidberg") + __author_mail__ = ("MikyWoW@seznam.cz", "zoidberg@mujmail.cz") + + FILE_NAME_PATTERN = r'<h3>([^<]+)</h3>' + FILE_SIZE_PATTERN = r'<td class="i">Velikost:</td>\s*<td class="h"><strong>\s*([0-9.]+) (kB|MB|GB)</strong></td>' + DOWNLOAD_URL_PATTERN = r'<a href="([^"]+)" title="Stahnout">([^<]+)</a>' + ERR_LOGIN_PATTERN = ur'<div class="error_div"><strong>Stahování je přístupné pouze přihlášeným uživatelům' + ERR_CREDIT_PATTERN = ur'<div class="error_div"><strong>Stahování zdarma je možné jen přes náš' + FILE_OFFLINE_PATTERN = ur'Nastala chyba 404|Soubor byl smazán' def setup(self): self.chunkLimit = 1 self.resumeDownload = True def process(self, pyfile): - name = pyfile.url - if "?" in pyfile.url: - name = re.findall("([^?=]+)", name)[-3] - - pyfile.name = re.findall("([^/=]+)", name)[-1] + if not self.account: self.fail("User not logged in") - self.html = self.load(pyfile.url) + self.html = self.load(pyfile.url, decode=True) + size, units = re.search(self.FILE_SIZE_PATTERN, self.html).groups() + pyfile.size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units] - if "Stahovn je pstupn pouze pihlenm uivatelm" in self.html: - self.fail("Nepihlen") + found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) + if found is not None: + self.logDebug(found) + link, pyfile.name = found.groups() + self.logInfo("Downloading file: %s (%s %s)" % (pyfile.name, size, units)) + self.logInfo("Premium link: %s" % link) + self.download(link) else: - start = self.html.index('<a href="http://s') - self.html = self.html[start+9:] - start = self.html.index('"') - self.html = self.html[0:start] - self.download(self.html)
\ No newline at end of file + self.logError("Download URL not found") + if re.search(self.ERR_LOGIN_PATTERN, self.html): + self.relogin() + self.retry(3,0,"User login failed") + elif re.search(self.ERR_CREDIT_PATTERN, self.html): + self.fail("Not enough credit left") + else: + self.fail("Download link not found")
\ No newline at end of file |