From fb65d5354c3cc80c3f48c3a2745b8dc01105edfd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 18 Dec 2014 16:02:29 +0100 Subject: Update account plugins --- module/plugins/accounts/AlldebridCom.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/accounts/AlldebridCom.py') diff --git a/module/plugins/accounts/AlldebridCom.py b/module/plugins/accounts/AlldebridCom.py index 1fb5e4b54..8fb841a39 100644 --- a/module/plugins/accounts/AlldebridCom.py +++ b/module/plugins/accounts/AlldebridCom.py @@ -23,8 +23,8 @@ class AlldebridCom(Account): def loadAccountInfo(self, user, req): data = self.getAccountData(user) - page = req.load("http://www.alldebrid.com/account/") - soup = BeautifulSoup(page) + html = req.load("http://www.alldebrid.com/account/") + soup = BeautifulSoup(html) #Try to parse expiration date directly from the control panel page (better accuracy) try: time_text = soup.find('div', attrs={'class': 'remaining_time_text'}).strong.string @@ -36,10 +36,10 @@ class AlldebridCom(Account): #Get expiration date from API except: data = self.getAccountData(user) - page = req.load("http://www.alldebrid.com/api.php", + html = req.load("http://www.alldebrid.com/api.php", get={'action': "info_user", 'login': user, 'pw': data['password']}) - self.logDebug(page) - xml = dom.parseString(page) + self.logDebug(html) + xml = dom.parseString(html) exp_time = time() + int(xml.getElementsByTagName("date")[0].childNodes[0].nodeValue) * 24 * 60 * 60 account_info = {"validuntil": exp_time, "trafficleft": -1} return account_info @@ -47,13 +47,13 @@ class AlldebridCom(Account): def login(self, user, data, req): urlparams = urlencode({'action': 'login', 'login_login': user, 'login_password': data['password']}) - page = req.load("http://www.alldebrid.com/register/?%s" % urlparams) + html = req.load("http://www.alldebrid.com/register/?%s" % urlparams) - if "This login doesn't exist" in page: + if "This login doesn't exist" in html: self.wrongPassword() - if "The password is not valid" in page: + if "The password is not valid" in html: self.wrongPassword() - if "Invalid captcha" in page: + if "Invalid captcha" in html: self.wrongPassword() -- cgit v1.2.3 From 522b3b5cb04ae74cd441b3c1a32512e8576da357 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 30 Dec 2014 02:12:47 +0100 Subject: [AlldebridCom] Code cosmetics --- module/plugins/accounts/AlldebridCom.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'module/plugins/accounts/AlldebridCom.py') diff --git a/module/plugins/accounts/AlldebridCom.py b/module/plugins/accounts/AlldebridCom.py index 8fb841a39..278f3af06 100644 --- a/module/plugins/accounts/AlldebridCom.py +++ b/module/plugins/accounts/AlldebridCom.py @@ -4,7 +4,6 @@ import re import xml.dom.minidom as dom from time import time -from urllib import urlencode from BeautifulSoup import BeautifulSoup @@ -25,35 +24,40 @@ class AlldebridCom(Account): data = self.getAccountData(user) html = req.load("http://www.alldebrid.com/account/") soup = BeautifulSoup(html) + #Try to parse expiration date directly from the control panel page (better accuracy) try: time_text = soup.find('div', attrs={'class': 'remaining_time_text'}).strong.string + self.logDebug("Account expires in: %s" % time_text) + p = re.compile('\d+') exp_data = p.findall(time_text) exp_time = time() + int(exp_data[0]) * 24 * 60 * 60 + int( exp_data[1]) * 60 * 60 + (int(exp_data[2]) - 1) * 60 + #Get expiration date from API except: data = self.getAccountData(user) html = req.load("http://www.alldebrid.com/api.php", get={'action': "info_user", 'login': user, 'pw': data['password']}) + self.logDebug(html) + xml = dom.parseString(html) exp_time = time() + int(xml.getElementsByTagName("date")[0].childNodes[0].nodeValue) * 24 * 60 * 60 + account_info = {"validuntil": exp_time, "trafficleft": -1} return account_info def login(self, user, data, req): - urlparams = urlencode({'action': 'login', 'login_login': user, 'login_password': data['password']}) - html = req.load("http://www.alldebrid.com/register/?%s" % urlparams) - - if "This login doesn't exist" in html: - self.wrongPassword() - - if "The password is not valid" in html: - self.wrongPassword() - - if "Invalid captcha" in html: + html = req.load("http://www.alldebrid.com/register/", + get={'action' : "login", + 'login_login' : user, + 'login_password': data['password']}) + + if "This login doesn't exist" in html \ + or "The password is not valid" in html \ + or "Invalid captcha" in html: self.wrongPassword() -- cgit v1.2.3 From 36e60a23497ae05736c24fed2f4ce936fb61f744 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 8 Jan 2015 23:31:33 +0100 Subject: "New Year" Update: account plugins --- module/plugins/accounts/AlldebridCom.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/accounts/AlldebridCom.py') diff --git a/module/plugins/accounts/AlldebridCom.py b/module/plugins/accounts/AlldebridCom.py index 278f3af06..1f2371e28 100644 --- a/module/plugins/accounts/AlldebridCom.py +++ b/module/plugins/accounts/AlldebridCom.py @@ -13,7 +13,7 @@ from module.plugins.Account import Account class AlldebridCom(Account): __name__ = "AlldebridCom" __type__ = "account" - __version__ = "0.22" + __version__ = "0.23" __description__ = """AllDebrid.com account plugin""" __license__ = "GPLv3" @@ -55,7 +55,8 @@ class AlldebridCom(Account): html = req.load("http://www.alldebrid.com/register/", get={'action' : "login", 'login_login' : user, - 'login_password': data['password']}) + 'login_password': data['password']}, + decode=True) if "This login doesn't exist" in html \ or "The password is not valid" in html \ -- cgit v1.2.3 From e1baccf1ec914563d3b2b845906cce024e7cd3b1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 13 Jan 2015 23:14:50 +0100 Subject: Replace 'except' with 'except Exception' --- module/plugins/accounts/AlldebridCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/accounts/AlldebridCom.py') diff --git a/module/plugins/accounts/AlldebridCom.py b/module/plugins/accounts/AlldebridCom.py index 1f2371e28..c830f0c09 100644 --- a/module/plugins/accounts/AlldebridCom.py +++ b/module/plugins/accounts/AlldebridCom.py @@ -37,7 +37,7 @@ class AlldebridCom(Account): exp_data[1]) * 60 * 60 + (int(exp_data[2]) - 1) * 60 #Get expiration date from API - except: + except Exception: data = self.getAccountData(user) html = req.load("http://www.alldebrid.com/api.php", get={'action': "info_user", 'login': user, 'pw': data['password']}) -- cgit v1.2.3