From 16af85004c84d0d6c626b4f8424ce9647669a0c1 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 9 Jun 2013 18:10:22 +0200 Subject: moved everything from module to pyload --- pyload/plugins/accounts/UploadedTo.py | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 pyload/plugins/accounts/UploadedTo.py (limited to 'pyload/plugins/accounts/UploadedTo.py') diff --git a/pyload/plugins/accounts/UploadedTo.py b/pyload/plugins/accounts/UploadedTo.py new file mode 100644 index 000000000..e10b93e8d --- /dev/null +++ b/pyload/plugins/accounts/UploadedTo.py @@ -0,0 +1,65 @@ +# -*- 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: mkaay +""" + +from module.plugins.Account import Account +import re +from time import time + +class UploadedTo(Account): + __name__ = "UploadedTo" + __version__ = "0.23" + __type__ = "account" + __description__ = """ul.net account plugin""" + __author_name__ = ("mkaay") + __author_mail__ = ("mkaay@mkaay.de") + + def loadAccountInfo(self, user, req): + + req.load("http://uploaded.net/language/en") + html = req.load("http://uploaded.net/me") + + premium = 'Premium' in html or 'Premium' in html + + if premium: + raw_traffic = re.search(r'([^<]+)', html).group(1) + raw_valid = re.search(r"Duration:\s*([^<]+)", html, re.MULTILINE).group(1).strip() + + traffic = int(self.parseTraffic(raw_traffic)) + + if raw_valid == "unlimited": + validuntil = -1 + else: + raw_valid = re.findall(r"(\d+) (weeks|days|hours)", raw_valid) + validuntil = time() + for n, u in raw_valid: + validuntil += 3600 * int(n) * {"weeks": 168, "days": 24, "hours": 1}[u] + + return {"validuntil":validuntil, "trafficleft":traffic, "maxtraffic":50*1024*1024} + else: + return {"premium" : False, "validuntil" : -1} + + def login(self, user, data, req): + + req.load("http://uploaded.net/language/en") + req.cj.setCookie("uploaded.net", "lang", "en") + + page = req.load("http://uploaded.net/io/login", post={ "id" : user, "pw" : data["password"], "_" : ""}) + + if "User and password do not match!" in page: + self.wrongPassword() -- cgit v1.2.3