summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/LetitbitNet.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/LetitbitNet.py')
-rw-r--r--module/plugins/hoster/LetitbitNet.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py
index f3921fdb7..6d5641778 100644
--- a/module/plugins/hoster/LetitbitNet.py
+++ b/module/plugins/hoster/LetitbitNet.py
@@ -16,7 +16,7 @@ from module.plugins.internal.CaptchaService import ReCaptcha
from module.plugins.internal.SimpleHoster import SimpleHoster, secondsToMidnight
-def api_download_info(url):
+def api_response(url):
json_data = ["yw7XQy2v9", ["download/info", {"link": url}]]
api_rep = getURL("http://api.letitbit.net/json",
post={'r': json_dumps(json_data)})
@@ -25,7 +25,7 @@ def api_download_info(url):
def getInfo(urls):
for url in urls:
- api_rep = api_download_info(url)
+ api_rep = api_response(url)
if api_rep['status'] == 'OK':
info = api_rep['data'][0]
yield (info['name'], info['size'], 2, url)
@@ -36,7 +36,7 @@ def getInfo(urls):
class LetitbitNet(SimpleHoster):
__name__ = "LetitbitNet"
__type__ = "hoster"
- __version__ = "0.28"
+ __version__ = "0.29"
__pattern__ = r'https?://(?:www\.)?(letitbit|shareflare)\.net/download/.+'
@@ -57,7 +57,7 @@ class LetitbitNet(SimpleHoster):
def getFileInfo(self):
- api_rep = api_download_info(self.pyfile.url)
+ api_rep = api_response(self.pyfile.url)
if api_rep['status'] == 'OK':
self.api_data = api_rep['data'][0]
self.pyfile.name = self.api_data['name']
@@ -66,12 +66,12 @@ class LetitbitNet(SimpleHoster):
self.offline()
- def handleFree(self):
+ def handleFree(self, pyfile):
action, inputs = self.parseHtmlForm('id="ifree_form"')
if not action:
self.error(_("ifree_form"))
- self.pyfile.size = float(inputs['sssize'])
+ pyfile.size = float(inputs['sssize'])
self.logDebug(action, inputs)
inputs['desc'] = ""
@@ -79,15 +79,20 @@ class LetitbitNet(SimpleHoster):
m = re.search(self.SECONDS_PATTERN, self.html)
seconds = int(m.group(1)) if m else 60
+
self.logDebug("Seconds found", seconds)
+
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)
res = self.load("http://letitbit.net/ajax/download3.php", post=" ", cookies=True)
if res != '1':
self.error(_("Unknown response - ajax_check_url"))
+
self.logDebug(res)
recaptcha = ReCaptcha(self)
@@ -96,21 +101,30 @@ 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)
+
res = self.load("http://letitbit.net/ajax/check_recaptcha.php", post=post_data, cookies=True)
+
self.logDebug(res)
+
if not res:
self.invalidCaptcha()
+
if res == "error_free_download_blocked":
self.logWarning(_("Daily limit reached"))
self.wait(secondsToMidnight(gmt=2), True)
+
if res == "error_wrong_captcha":
self.invalidCaptcha()
self.retry()
+
elif res.startswith('['):
urls = json_loads(res)
+
elif res.startswith('http://'):
urls = [res]
+
else:
self.error(_("Unknown response - captcha check"))
@@ -126,11 +140,11 @@ class LetitbitNet(SimpleHoster):
self.fail(_("Download did not finish correctly"))
- def handlePremium(self):
+ def handlePremium(self, pyfile):
api_key = self.user
premium_key = self.account.getAccountData(self.user)['password']
- json_data = [api_key, ["download/direct_links", {"pass": premium_key, "link": self.pyfile.url}]]
+ json_data = [api_key, ["download/direct_links", {"pass": premium_key, "link": pyfile.url}]]
api_rep = self.load('http://api.letitbit.net/json', post={'r': json_dumps(json_data)})
self.logDebug("API Data: " + api_rep)
api_rep = json_loads(api_rep)