diff options
Diffstat (limited to 'module/plugins/accounts/UlozTo.py')
-rw-r--r-- | module/plugins/accounts/UlozTo.py | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/module/plugins/accounts/UlozTo.py b/module/plugins/accounts/UlozTo.py index 6b1067f28..7236a4fa8 100644 --- a/module/plugins/accounts/UlozTo.py +++ b/module/plugins/accounts/UlozTo.py @@ -2,42 +2,49 @@ import re +from urlparse import urljoin + from module.plugins.Account import Account class UlozTo(Account): - __name__ = "UlozTo" - __version__ = "0.06" - __type__ = "account" + __name__ = "UlozTo" + __type__ = "account" + __version__ = "0.10" + __description__ = """Uloz.to account plugin""" - __author_name__ = ("zoidberg", "pulpe") - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("pulpe", None)] + + + TRAFFIC_LEFT_PATTERN = r'<li class="menu-kredit"><a .*?title="[^"]*?GB = ([\d.]+) MB"' - TRAFFIC_LEFT_PATTERN = r'<li class="menu-kredit"><a href="/kredit" title="[^"]*?GB = ([0-9.]+) MB"' def loadAccountInfo(self, user, req): - #this cookie gets lost somehow after each request - self.phpsessid = req.cj.getCookie("ULOSESSID") html = req.load("http://www.ulozto.net/", decode=True) - req.cj.setCookie("www.ulozto.net", "ULOSESSID", self.phpsessid) - found = re.search(self.TRAFFIC_LEFT_PATTERN, html) - trafficleft = int(float(found.group(1).replace(' ', '').replace(',', '.')) * 1000 * 1.048) if found else 0 - self.premium = True if trafficleft else False + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + + trafficleft = float(m.group(1).replace(' ', '').replace(',', '.')) * 1000 * 1.048 if m else 0 + premium = True if trafficleft else False + + return {'validuntil': -1, 'trafficleft': trafficleft, 'premium': premium} - return {"validuntil": -1, "trafficleft": trafficleft} def login(self, user, data, req): login_page = req.load('http://www.ulozto.net/?do=web-login', decode=True) - action = re.findall('<form action="(.+?)"', login_page)[1].replace('&', '&') - token = re.search('_token_" value="(.+?)"', login_page).group(1) - - html = req.load('http://www.ulozto.net'+action, post={ - "_token_": token, - "login": "Submit", - "password": data['password'], - "username": user - }, decode=True) + action = re.findall('<form action="(.+?)"', login_page)[1].replace('&', '&') + token = re.search('_token_" value="(.+?)"', login_page).group(1) + + html = req.load(urljoin("http://www.ulozto.net/", action), + post={'_token_' : token, + 'do' : "loginForm-submit", + 'login' : u"Přihlásit", + 'password': data['password'], + 'username': user, + 'remember': "on"}, + decode=True) if '<div class="flash error">' in html: self.wrongPassword() |