summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Nitzo <nitzo2001@yahoo.com> 2016-05-01 02:36:40 +0200
committerGravatar Nitzo <nitzo2001@yahoo.com> 2016-05-01 02:36:40 +0200
commit0fd68d59c33d280a7e039d05900583f0ded824ca (patch)
tree34aa34f4a0d936dda8e24004df9c90e02ec86b33 /module
parent[Plugin] Version up (diff)
downloadpyload-0fd68d59c33d280a7e039d05900583f0ded824ca.tar.xz
[TurbobitNet] fix #2445
Diffstat (limited to 'module')
-rw-r--r--module/plugins/accounts/TurbobitNet.py45
1 files changed, 35 insertions, 10 deletions
diff --git a/module/plugins/accounts/TurbobitNet.py b/module/plugins/accounts/TurbobitNet.py
index da183bebe..735fe1673 100644
--- a/module/plugins/accounts/TurbobitNet.py
+++ b/module/plugins/accounts/TurbobitNet.py
@@ -4,24 +4,27 @@ import re
import time
from module.plugins.internal.Account import Account
-from module.plugins.internal.misc import set_cookie
+from module.plugins.internal.misc import parse_html_form, set_cookie
class TurbobitNet(Account):
__name__ = "TurbobitNet"
__type__ = "account"
- __version__ = "0.09"
+ __version__ = "0.10"
__status__ = "testing"
__description__ = """TurbobitNet account plugin"""
__license__ = "GPLv3"
- __authors__ = [("zoidberg", "zoidberg@mujmail.cz")]
+ __authors__ = [("zoidberg", "zoidberg@mujmail.cz" ),
+ ("GammaC0de", "nitzo2001[AT]yahoo[DOT]com")]
+
+ LOGIN_FAIL_PATTERN = r'>(?:E-Mail address appears to be invalid\. Please try again|Incorrect login or password)</div>'
def grab_info(self, user, password, data):
- html = self.load("http://turbobit.net")
+ html = self.load("http://turbobit.net/")
- m = re.search(r'<u>Turbo Access</u> to ([\d.]+)', html)
+ m = re.search(r'>Turbo access till ([\d.]+)<', html)
if m is not None:
premium = True
validuntil = time.mktime(time.strptime(m.group(1), "%d.%m.%Y"))
@@ -35,10 +38,32 @@ class TurbobitNet(Account):
def signin(self, user, password, data):
set_cookie(self.req.cj, "turbobit.net", "user_lang", "en")
- html = self.load("http://turbobit.net/user/login",
- post={"user[login]" : user,
- "user[pass]" : password,
- "user[submit]": "Login"})
+ self.data = self.load("http://turbobit.net/login")
+
+ if "<a href='/user/logout'" in self.data:
+ self.skip_login()
+
+ action, inputs = parse_html_form('class="form-horizontal login mail"', self.data)
+ if not inputs:
+ self.fail_login(_("Login form not found"))
+
+ inputs['user[login]'] = user
+ inputs['user[pass]'] = password
+ inputs['user[submit]'] = "Sign in"
+
+ if inputs.get('user[captcha_type]'):
+ self.fail_login(_("Logging in with captcha is not supported, please disable catcha in turbobit's account settings"))
- if not '<div class="menu-item user-name">' in html:
+ self.data = self.load("http://turbobit.net/user/login", post=inputs)
+
+ if "<a href='/user/logout'" in self.data:
+ self.log_debug(_("Login successful"))
+
+ elif re.search(self.LOGIN_FAIL_PATTERN, self.data):
self.fail_login()
+
+ elif ">Please enter the captcha code.</div>" in self.data:
+ self.fail_login(_("Logging in with captcha is not supported, please disable catcha in turbobit's account settings"))
+
+ else:
+ self.fail_login(_("Unknown response"))