diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-09-07 23:40:50 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-09-14 10:58:42 +0200 |
commit | 887ad58e4c6c20b992311bbdf931bcd18e73d384 (patch) | |
tree | f31beb241bacca0bfea4c1acc4e9ace813755cef /module/plugins/hoster/LetitbitNet.py | |
parent | [AccountManager] Fixed #733 (diff) | |
parent | [File4safe] distributing LINK_PATTERN (diff) | |
download | pyload-887ad58e4c6c20b992311bbdf931bcd18e73d384.tar.xz |
Merge branch 'stable' into 0.4.10
Conflicts:
module/plugins/Account.py
module/plugins/AccountManager.py
module/plugins/Hook.py
module/plugins/OCR.py
module/plugins/Plugin.py
module/plugins/PluginManager.py
module/plugins/ReCaptcha.py
module/plugins/accounts/Ftp.py
module/plugins/accounts/Http.py
module/plugins/internal/MultiHoster.py
module/plugins/ocr/GigasizeCom.py
module/plugins/ocr/LinksaveIn.py
module/plugins/ocr/NetloadIn.py
module/plugins/ocr/ShareonlineBiz.py
Diffstat (limited to 'module/plugins/hoster/LetitbitNet.py')
-rw-r--r-- | module/plugins/hoster/LetitbitNet.py | 83 |
1 files changed, 37 insertions, 46 deletions
diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 58532fd28..3159be4f1 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -1,40 +1,25 @@ # -*- 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 -""" - +# # API Documentation: # http://api.letitbit.net/reg/static/api.pdf - -# Test links (random.bin): +# +# Test links: # http://letitbit.net/download/07874.0b5709a7d3beee2408bb1f2eefce/random.bin.html import re -import urllib -from module.plugins.internal.SimpleHoster import SimpleHoster +from urllib import urlencode, urlopen + from module.common.json_layer import json_loads, json_dumps +from module.plugins.hoster.UnrestrictLi import secondsToMidnight from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster def api_download_info(url): - json_data = ['yw7XQy2v9', ["download/info", {"link": url}]] - post_data = urllib.urlencode({'r': json_dumps(json_data)}) - api_rep = urllib.urlopen('http://api.letitbit.net/json', data=post_data).read() + json_data = ["yw7XQy2v9", ["download/info", {"link": url}]] + post_data = urlencode({'r': json_dumps(json_data)}) + api_rep = urlopen("http://api.letitbit.net/json", data=post_data).read() return json_loads(api_rep) @@ -51,20 +36,23 @@ def getInfo(urls): class LetitbitNet(SimpleHoster): __name__ = "LetitbitNet" __type__ = "hoster" + __version__ = "0.24" + __pattern__ = r'http://(?:www\.)?(letitbit|shareflare).net/download/.*' - __version__ = "0.23" + __description__ = """Letitbit.net hoster plugin""" __author_name__ = ("zoidberg", "z00nx") __author_mail__ = ("zoidberg@mujmail.cz", "z00nx0@gmail.com") - CHECK_URL_PATTERN = r"ajax_check_url\s*=\s*'((http://[^/]+)[^']+)';" - SECONDS_PATTERN = r"seconds\s*=\s*(\d+);" - CAPTCHA_CONTROL_FIELD = r"recaptcha_control_field\s=\s'(?P<value>[^']+)'" - - DOMAIN = "http://letitbit.net" FILE_URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "letitbit.net")] + + HOSTER_NAME = "letitbit.net" + + SECONDS_PATTERN = r'seconds\s*=\s*(\d+);' + CAPTCHA_CONTROL_FIELD = r"recaptcha_control_field\s=\s'(?P<value>[^']+)'" RECAPTCHA_KEY = "6Lc9zdMSAAAAAF-7s2wuQ-036pLRbM0p8dDaQdAM" + def setup(self): self.resumeDownload = True #TODO confirm that resume works @@ -82,36 +70,39 @@ class LetitbitNet(SimpleHoster): action, inputs = self.parseHtmlForm('id="ifree_form"') if not action: self.parseError("page 1 / ifree_form") + + domain = "http://www." + self.HOSTER_NAME self.pyfile.size = float(inputs['sssize']) self.logDebug(action, inputs) inputs['desc'] = "" - self.html = self.load(self.DOMAIN + action, post=inputs, cookies=True) + self.html = self.load(domain + action, post=inputs, cookies=True) # action, inputs = self.parseHtmlForm('id="d3_form"') - # if not action: self.parseError("page 2 / d3_form") - # #self.logDebug(action, inputs) + # if not action: + # self.parseError("page 2 / d3_form") + # self.logDebug(action, inputs) # # self.html = self.load(action, post = inputs, cookies = True) # # try: # ajax_check_url, captcha_url = re.search(self.CHECK_URL_PATTERN, self.html).groups() - # found = re.search(self.SECONDS_PATTERN, self.html) - # seconds = int(found.group(1)) if found else 60 + # m = re.search(self.SECONDS_PATTERN, self.html) + # seconds = int(m.group(1)) if m else 60 # self.wait(seconds+1) # except Exception, e: # self.logError(e) # self.parseError("page 3 / js") - found = re.search(self.SECONDS_PATTERN, self.html) - seconds = int(found.group(1)) if found else 60 + m = re.search(self.SECONDS_PATTERN, self.html) + seconds = int(m.group(1)) if m else 60 self.logDebug("Seconds found", seconds) - found = re.search(self.CAPTCHA_CONTROL_FIELD, self.html) - recaptcha_control_field = found.group(1) + m = re.search(self.CAPTCHA_CONTROL_FIELD, self.html) + recaptcha_control_field = m.group(1) self.logDebug("ReCaptcha control field found", recaptcha_control_field) self.wait(seconds + 1) - response = self.load("%s/ajax/download3.php" % self.DOMAIN, post=" ", cookies=True) + response = self.load("%s/ajax/download3.php" % domain, post=" ", cookies=True) if response != '1': self.parseError('Unknown response - ajax_check_url') self.logDebug(response) @@ -121,15 +112,15 @@ class LetitbitNet(SimpleHoster): post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": response, "recaptcha_control_field": recaptcha_control_field} self.logDebug("Post data to send", post_data) - response = self.load('%s/ajax/check_recaptcha.php' % self.DOMAIN, post=post_data, cookies=True) + response = self.load('%s/ajax/check_recaptcha.php' % domain, post=post_data, cookies=True) self.logDebug(response) if not response: self.invalidCaptcha() if response == "error_free_download_blocked": - self.logInfo("Daily limit reached, waiting 24 hours") - self.wait(24 * 60 * 60) + self.logWarning("Daily limit reached") + self.wait(secondsToMidnight(gmt=2), True) if response == "error_wrong_captcha": - self.logInfo("Wrong Captcha") + self.logError("Wrong Captcha") self.invalidCaptcha() self.retry() elif response.startswith('['): @@ -153,7 +144,7 @@ class LetitbitNet(SimpleHoster): def handlePremium(self): api_key = self.user - premium_key = self.account.getAccountData(self.user)["password"] + premium_key = self.account.getAccountData(self.user)['password'] json_data = [api_key, ["download/direct_links", {"pass": premium_key, "link": self.pyfile.url}]] api_rep = self.load('http://api.letitbit.net/json', post={'r': json_dumps(json_data)}) |