From 2404538888ced4e6964df55823d0514b1c0ba685 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 8 Jul 2014 20:03:27 +0200 Subject: rapideo.pl files added --- module/plugins/accounts/RapideoPl.py | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 module/plugins/accounts/RapideoPl.py (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py new file mode 100644 index 000000000..f7343cf02 --- /dev/null +++ b/module/plugins/accounts/RapideoPl.py @@ -0,0 +1,102 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@author: Pawel W. +""" + +from datetime import datetime + +from module.plugins.Account import Account +from module.plugins.internal.SimpleHoster import parseHtmlForm +import re +from time import mktime, strptime +import module.lib.beaker.crypto as crypto + +try: + from json import loads +except ImportError: + from simplejson import loads + +class RapideoPl(Account): + __name__ = "RapideoPl" + __version__ = "0.01" + __type__ = "account" + __description__ = "Rapideo.pl account plugin" + __author_name__ = ("goddie") + __author_mail__ = ("dev@rapideo.pl") + + _api_url = "http://enc.rapideo.pl" + + _api_query = { + "site": "newrd", + "username": "", + "password": "", + "output": "json", + "loc": "1", + "info": "1" + } + + _req = None + _usr = None + _pwd = None + + def loadAccountInfo(self, name, req): + + self._req = req + + try: + result = loads(self.runAuthQuery()) + except: + #todo: ret? + return + + premium = False + valid_untill = -1 + + is_premium = "expire" in result.keys() and result["expire"] is not None + + if is_premium: + + premium = True + valid_untill = mktime(datetime.fromtimestamp(int(result["expire"])).timetuple()) + + traffic_left = result["balance"] + + return ({ + "validuntil": valid_untill, + "trafficleft": traffic_left, + "premium": premium + }) + + def login(self, user, data, req): + + self._usr = user + self._pwd = crypto.md5(data["password"]).hexdigest() + + self._req = req + + try: + response = loads(self.runAuthQuery()) + except: + self.wrongPassword() + + if "errno" in response.keys(): + self.wrongPassword() + + data['usr'] = user + data['pwd'] = crypto.md5(data['password']).hexdigest() + + def createAuthQuery(self): + + query = self._api_query + query["username"] = self._usr + query["password"] = self._pwd + + return query + + def runAuthQuery(self): + + data = self._req.load(self._api_url, post=self.createAuthQuery()) + + return data \ No newline at end of file -- cgit v1.2.3 From fa0db462b06e2d6b64b3b07ed2d7d6c31de22448 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 8 Jul 2014 20:10:53 +0200 Subject: to-do & small simplification in username and password saving --- module/plugins/accounts/RapideoPl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index f7343cf02..8abfa4989 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -48,7 +48,7 @@ class RapideoPl(Account): try: result = loads(self.runAuthQuery()) except: - #todo: ret? + #todo: return or let it be thrown? return premium = False @@ -84,8 +84,8 @@ class RapideoPl(Account): if "errno" in response.keys(): self.wrongPassword() - data['usr'] = user - data['pwd'] = crypto.md5(data['password']).hexdigest() + data['usr'] = self._usr + data['pwd'] = self._pwd def createAuthQuery(self): -- cgit v1.2.3 From ea1cbeda0006bbf427223686892c9e6f87cfbe94 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 8 Jul 2014 21:36:14 +0200 Subject: remove redundant author information --- module/plugins/accounts/RapideoPl.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 8abfa4989..679f7eab0 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -1,10 +1,6 @@ # !/usr/bin/env python # -*- coding: utf-8 -*- -""" -@author: Pawel W. -""" - from datetime import datetime from module.plugins.Account import Account -- cgit v1.2.3 From 2ed13d51ab8cd28f2f3db4caabde9b6d2e2cec25 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 11:55:23 +0200 Subject: remove enviroment line --- module/plugins/accounts/RapideoPl.py | 1 - 1 file changed, 1 deletion(-) (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 679f7eab0..0463bba69 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -1,4 +1,3 @@ -# !/usr/bin/env python # -*- coding: utf-8 -*- from datetime import datetime -- cgit v1.2.3 From 2e8ed2bf0b357e907f6921c7bb88719bb347367b Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 13:47:49 +0200 Subject: remove blank lines and unused imports --- module/plugins/accounts/RapideoPl.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 0463bba69..853731f26 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -3,9 +3,7 @@ from datetime import datetime from module.plugins.Account import Account -from module.plugins.internal.SimpleHoster import parseHtmlForm -import re -from time import mktime, strptime +from time import mktime import module.lib.beaker.crypto as crypto try: @@ -13,6 +11,7 @@ try: except ImportError: from simplejson import loads + class RapideoPl(Account): __name__ = "RapideoPl" __version__ = "0.01" @@ -37,40 +36,32 @@ class RapideoPl(Account): _pwd = None def loadAccountInfo(self, name, req): - self._req = req - try: result = loads(self.runAuthQuery()) except: - #todo: return or let it be thrown? + # todo: return or let it be thrown? return premium = False valid_untill = -1 - is_premium = "expire" in result.keys() and result["expire"] is not None - if is_premium: - premium = True valid_untill = mktime(datetime.fromtimestamp(int(result["expire"])).timetuple()) traffic_left = result["balance"] return ({ - "validuntil": valid_untill, - "trafficleft": traffic_left, - "premium": premium - }) + "validuntil": valid_untill, + "trafficleft": traffic_left, + "premium": premium + }) def login(self, user, data, req): - self._usr = user self._pwd = crypto.md5(data["password"]).hexdigest() - self._req = req - try: response = loads(self.runAuthQuery()) except: @@ -78,12 +69,10 @@ class RapideoPl(Account): if "errno" in response.keys(): self.wrongPassword() - data['usr'] = self._usr data['pwd'] = self._pwd def createAuthQuery(self): - query = self._api_query query["username"] = self._usr query["password"] = self._pwd @@ -91,7 +80,6 @@ class RapideoPl(Account): return query def runAuthQuery(self): - data = self._req.load(self._api_url, post=self.createAuthQuery()) return data \ No newline at end of file -- cgit v1.2.3 From 25d2cceff065a0268a7e183449ef54edf98f1783 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 13:49:12 +0200 Subject: simplify json loads, replace crypto with hashlib --- module/plugins/accounts/RapideoPl.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 853731f26..6ace9ede0 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -1,16 +1,11 @@ # -*- coding: utf-8 -*- from datetime import datetime +import hashlib from module.plugins.Account import Account from time import mktime -import module.lib.beaker.crypto as crypto - -try: - from json import loads -except ImportError: - from simplejson import loads - +from module.common.json_layer import json_loads as loads class RapideoPl(Account): __name__ = "RapideoPl" @@ -60,7 +55,7 @@ class RapideoPl(Account): def login(self, user, data, req): self._usr = user - self._pwd = crypto.md5(data["password"]).hexdigest() + self._pwd = hashlib.md5(data["password"]).hexdigest() self._req = req try: response = loads(self.runAuthQuery()) -- cgit v1.2.3 From 88ba5ecd9027ffa7a8bb5eb207085295ad35724d Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 13:49:42 +0200 Subject: newline fix --- module/plugins/accounts/RapideoPl.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 6ace9ede0..cbec9809a 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -7,6 +7,7 @@ from module.plugins.Account import Account from time import mktime from module.common.json_layer import json_loads as loads + class RapideoPl(Account): __name__ = "RapideoPl" __version__ = "0.01" -- cgit v1.2.3 From d0eea8f9baced6fd882e396e019940cff5fcf777 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 13:50:58 +0200 Subject: replace is_premium with direct expression, remove explicit "is not None" --- module/plugins/accounts/RapideoPl.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index cbec9809a..f35d23827 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -41,8 +41,7 @@ class RapideoPl(Account): premium = False valid_untill = -1 - is_premium = "expire" in result.keys() and result["expire"] is not None - if is_premium: + if "expire" in result.keys() and result["expire"]: premium = True valid_untill = mktime(datetime.fromtimestamp(int(result["expire"])).timetuple()) -- cgit v1.2.3 From 005710831caa04bbe372b54ac357658963fe02bb Mon Sep 17 00:00:00 2001 From: synweap15 Date: Mon, 3 Nov 2014 14:44:44 +0100 Subject: New __authors__ key, added __license__ --- module/plugins/accounts/RapideoPl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index f35d23827..438ce7ad3 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -13,8 +13,8 @@ class RapideoPl(Account): __version__ = "0.01" __type__ = "account" __description__ = "Rapideo.pl account plugin" - __author_name__ = ("goddie") - __author_mail__ = ("dev@rapideo.pl") + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@rapideo.pl")] _api_url = "http://enc.rapideo.pl" -- cgit v1.2.3