From 3c7b7eaa189dd030712290fea2b2655b69fd6c05 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 4 Jun 2011 17:22:51 +0200 Subject: x7.to plugin, by ernieb --- module/plugins/accounts/X7To.py | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 module/plugins/accounts/X7To.py (limited to 'module/plugins/accounts/X7To.py') diff --git a/module/plugins/accounts/X7To.py b/module/plugins/accounts/X7To.py new file mode 100644 index 000000000..1e3ef782e --- /dev/null +++ b/module/plugins/accounts/X7To.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . + + @author: ernieb +""" + +import re +from time import strptime, mktime + +from module.plugins.Account import Account + +class X7To(Account): + __name__ = "X7To" + __version__ = "0.1" + __type__ = "account" + __description__ = """X7.To account plugin""" + __author_name__ = ("ernieb") + __author_mail__ = ("ernieb") + + def loadAccountInfo(self, user, req): + page = req.load("http://www.x7.to/my") + + valid = re.search("Premium-Mitglied bis ([0-9]*-[0-9]*-[0-9]*)", page, re.IGNORECASE).group(1) + valid = int(mktime(strptime(valid, "%Y-%m-%d"))) + + trafficleft = re.search('([\d]*)[,]?[\d]?[\d]? (KB|MB|GB)', page, + re.IGNORECASE) + if trafficleft: + units = float(trafficleft.group(1)) + pow = {'KB': 0, 'MB': 1, 'GB': 2}[trafficleft.group(2)] + trafficleft = int(units * 1024 ** pow) + else: + trafficleft = -1 + + return {"trafficleft": trafficleft, "validuntil": valid} + + + def login(self, user, data, req): + #req.cj.setCookie("share.cx", "lang", "english") + page = req.load("http://x7.to/lang/en", None, {}) + page = req.load("http://x7.to/james/login", None, + {"redirect": "http://www.x7.to/", "id": user, "pw": data['password'], "submit": "submit"}) + + if "Username and password are not matching." in page: + self.wrongPassword() \ No newline at end of file -- cgit v1.2.3