summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-02 22:14:08 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-02 22:14:08 +0200
commit5a679eeada699b74e29bf8947d25ae3e83289180 (patch)
tree61ee647b97ecf14a7d3516f29962507e70b3a560 /module/plugins/accounts
parenturlencode fix (diff)
downloadpyload-5a679eeada699b74e29bf8947d25ae3e83289180.tar.xz
improved accountmanager
Diffstat (limited to 'module/plugins/accounts')
-rw-r--r--module/plugins/accounts/DepositfilesCom.py22
-rw-r--r--module/plugins/accounts/FileserveCom.py34
-rw-r--r--module/plugins/accounts/HotfileCom.py50
-rw-r--r--module/plugins/accounts/MegauploadCom.py2
-rw-r--r--module/plugins/accounts/NetloadIn.py2
-rw-r--r--module/plugins/accounts/RapidshareCom.py57
-rw-r--r--module/plugins/accounts/ShareonlineBiz.py23
-rw-r--r--module/plugins/accounts/UploadedTo.py34
8 files changed, 91 insertions, 133 deletions
diff --git a/module/plugins/accounts/DepositfilesCom.py b/module/plugins/accounts/DepositfilesCom.py
index 1410e6a37..70741da0b 100644
--- a/module/plugins/accounts/DepositfilesCom.py
+++ b/module/plugins/accounts/DepositfilesCom.py
@@ -29,24 +29,18 @@ class DepositfilesCom(Account):
__author_name__ = ("mkaay")
__author_mail__ = ("mkaay@mkaay.de")
- def getAccountInfo(self, user):
- try:
- req = self.core.requestFactory.getRequest(self.__name__, user)
+ def loadAccountInfo(self, user):
+ req = self.getAccountRequest(user)
- src = req.load("http://depositfiles.com/de/gold/")
- validuntil = re.search("noch den Gold-Zugriff: <b>(.*?)</b></div>", src).group(1)
+ src = req.load("http://depositfiles.com/de/gold/")
+ validuntil = re.search("noch den Gold-Zugriff: <b>(.*?)</b></div>", src).group(1)
- validuntil = int(mktime(strptime(validuntil, "%Y-%m-%d %H:%M:%S")))
+ validuntil = int(mktime(strptime(validuntil, "%Y-%m-%d %H:%M:%S")))
- out = Account.getAccountInfo(self, user)
-
- tmp = {"validuntil":validuntil, "trafficleft":-1}
- out.update(tmp)
- return out
- except:
- return Account.getAccountInfo(self, user)
+ tmp = {"validuntil":validuntil, "trafficleft":-1}
+ return tmp
def login(self, user, data):
- req = self.core.requestFactory.getRequest(self.__name__, user)
+ req = self.getAccountRequest(user)
req.load("http://depositfiles.com/de/gold/payment.php")
req.load("http://depositfiles.com/de/login.php", get={"return": "/de/gold/payment.php"}, post={"login": user, "password": data["password"]})
diff --git a/module/plugins/accounts/FileserveCom.py b/module/plugins/accounts/FileserveCom.py
index 1fdb4c40b..27cad18bd 100644
--- a/module/plugins/accounts/FileserveCom.py
+++ b/module/plugins/accounts/FileserveCom.py
@@ -29,28 +29,22 @@ class FileserveCom(Account):
__author_name__ = ("mkaay")
__author_mail__ = ("mkaay@mkaay.de")
- def getAccountInfo(self, user):
- try:
- req = self.core.requestFactory.getRequest(self.__name__, user)
-
- src = req.load("http://fileserve.com/dashboard.php", cookies=True)
-
- out = Account.getAccountInfo(self, user)
-
- m = re.search(r"<td><h4>Premium Until</h4></th> <td><h5>(.*?) E(.)T</h5></td>", src)
- if m:
- zone = -5 if m.group(2) == "S" else -4
- validuntil = int(mktime(strptime(m.group(1), "%d %B %Y"))) + 24*3600 + (zone*3600)
- tmp = {"validuntil":validuntil, "trafficleft":-1}
- else:
- tmp = {"trafficleft":-1}
- out.update(tmp)
- return out
- except:
- return Account.getAccountInfo(self, user)
+ def loadAccountInfo(self, user):
+ req = self.getAccountRequest(user)
+
+ src = req.load("http://fileserve.com/dashboard.php", cookies=True)
+
+ m = re.search(r"<td><h4>Premium Until</h4></th> <td><h5>(.*?) E(.)T</h5></td>", src)
+ if m:
+ zone = -5 if m.group(2) == "S" else -4
+ validuntil = int(mktime(strptime(m.group(1), "%d %B %Y"))) + 24*3600 + (zone*3600)
+ tmp = {"validuntil":validuntil, "trafficleft":-1}
+ else:
+ tmp = {"trafficleft":-1}
+ return tmp
def login(self, user, data):
- req = self.core.requestFactory.getRequest(self.__name__, user)
+ req = self.getAccountRequest(user)
req.load("http://fileserve.com/login.php",
post={"loginUserName": user, "loginUserPassword": data["password"],
"autoLogin": "on", "loginFormSubmit": "Login"}, cookies=True)
diff --git a/module/plugins/accounts/HotfileCom.py b/module/plugins/accounts/HotfileCom.py
index 6b92df514..5a3fdd6a5 100644
--- a/module/plugins/accounts/HotfileCom.py
+++ b/module/plugins/accounts/HotfileCom.py
@@ -29,31 +29,25 @@ class HotfileCom(Account):
__author_name__ = ("mkaay")
__author_mail__ = ("mkaay@mkaay.de")
- def getAccountInfo(self, user):
- try:
- req = self.core.requestFactory.getRequest(self.__name__, user)
-
- resp = self.apiCall("getuserinfo", user=user)
- if resp.startswith("."):
- self.core.debug("HotfileCom API Error: %s" % resp)
- raise Exception
- info = {}
- for p in resp.split("&"):
- key, value = p.split("=")
- info[key] = value
-
- info["premium_until"] = info["premium_until"].replace("T"," ")
- zone = info["premium_until"][19:]
- info["premium_until"] = info["premium_until"][:19]
- zone = int(zone[:3])
-
- validuntil = int(mktime(strptime(info["premium_until"], "%Y-%m-%d %H:%M:%S"))) + (zone*3600)
- out = Account.getAccountInfo(self, user)
- tmp = {"validuntil":validuntil, "trafficleft":-1}
- out.update(tmp)
- return out
- except:
- return Account.getAccountInfo(self, user)
+ def loadAccountInfo(self, user):
+ resp = self.apiCall("getuserinfo", user=user)
+ if resp.startswith("."):
+ self.core.debug("HotfileCom API Error: %s" % resp)
+ raise Exception
+ info = {}
+ for p in resp.split("&"):
+ key, value = p.split("=")
+ info[key] = value
+
+ info["premium_until"] = info["premium_until"].replace("T"," ")
+ zone = info["premium_until"][19:]
+ info["premium_until"] = info["premium_until"][:19]
+ zone = int(zone[:3])
+
+ validuntil = int(mktime(strptime(info["premium_until"], "%Y-%m-%d %H:%M:%S"))) + (zone*3600)
+
+ tmp = {"validuntil":validuntil, "trafficleft":-1}
+ return tmp
def apiCall(self, method, post={}, user=None):
if user:
@@ -64,7 +58,7 @@ class HotfileCom(Account):
else:
user, data = self.accounts.items()[0]
- req = self.core.requestFactory.getRequest(self.__name__, user)
+ req = self.getAccountRequest(user)
digest = req.load("http://api.hotfile.com/", post={"action":"getdigest"})
h = hashlib.md5()
@@ -80,8 +74,8 @@ class HotfileCom(Account):
return req.load("http://api.hotfile.com/", post=post)
def login(self, user, data):
- req = self.core.requestFactory.getRequest(self.__name__, user)
- cj = self.core.requestFactory.getCookieJar(self.__name__, user)
+ req = self.getAccountRequest(user)
+ cj = self.getAccountCookies(user)
cj.setCookie("hotfile.com", "lang", "en")
req.load("http://hotfile.com/", cookies=True)
req.load("http://hotfile.com/login.php", post={"returnto": "/", "user": user, "pass": data["password"]}, cookies=True)
diff --git a/module/plugins/accounts/MegauploadCom.py b/module/plugins/accounts/MegauploadCom.py
index 36779d4f5..77a11fe25 100644
--- a/module/plugins/accounts/MegauploadCom.py
+++ b/module/plugins/accounts/MegauploadCom.py
@@ -28,5 +28,5 @@ class MegauploadCom(Account):
__author_mail__ = ("RaNaN@pyload.org")
def login(self, user, data):
- req = self.core.requestFactory.getRequest(self.__name__, user)
+ req = self.getAccountRequest(user)
req.load("http://www.megaupload.com/?c=login&next=c%3Dpremium", post={ "username" : user, "password" : data["password"], "login" :"1"}, cookies=True)
diff --git a/module/plugins/accounts/NetloadIn.py b/module/plugins/accounts/NetloadIn.py
index 5743c7835..28b3a1c56 100644
--- a/module/plugins/accounts/NetloadIn.py
+++ b/module/plugins/accounts/NetloadIn.py
@@ -28,6 +28,6 @@ class NetloadIn(Account):
__author_mail__ = ("RaNaN@pyload.org")
def login(self, user, data):
- req = self.core.requestFactory.getRequest(self.__name__, user)
+ req = self.getAccountRequest(user)
req.load("http://netload.in/index.php", None, { "txtuser" : user, "txtpass" : data['password'], "txtcheck" : "login", "txtlogin" : ""}, cookies=True)
diff --git a/module/plugins/accounts/RapidshareCom.py b/module/plugins/accounts/RapidshareCom.py
index c9766cd57..ccc0d0fb2 100644
--- a/module/plugins/accounts/RapidshareCom.py
+++ b/module/plugins/accounts/RapidshareCom.py
@@ -27,44 +27,35 @@ class RapidshareCom(Account):
__author_name__ = ("mkaay")
__author_mail__ = ("mkaay@mkaay.de")
- def getAccountInfo(self, user):
- try:
- data = None
- for account in self.accounts.items():
- if account[0] == user:
- data = account[1]
- if not data:
- raise Exception
- req = self.core.requestFactory.getRequest(self.__name__, user)
- api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi"
- api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": user, "password": data["password"], "withcookie": 1}
- src = req.load(api_url_base, cookies=False, get=api_param_prem)
- if src.startswith("ERROR"):
- raise Exception
- fields = src.split("\n")
- info = {}
- for t in fields:
- if not t.strip():
- continue
- k, v = t.split("=")
- info[k] = v
-
- out = Account.getAccountInfo(self, user)
- restkb = int(info["tskb"])
- maxtraffic = int(info["rapids"])/14 * (5*1024*1024) + restkb
- tmp = {"validuntil":int(info["billeduntil"]), "trafficleft":maxtraffic if int(info["autorefill"]) else restkb, "maxtraffic":maxtraffic}
- out.update(tmp)
- return out
- except:
- return Account.getAccountInfo(self, user)
+ def loadAccountInfo(self, user):
+ data = self.getAccountData(user)
+ req = self.getAccountRequest(user)
+ api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi"
+ api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": user, "password": data["password"], "withcookie": 1}
+ src = req.load(api_url_base, cookies=False, get=api_param_prem)
+ if src.startswith("ERROR"):
+ raise Exception(src)
+ fields = src.split("\n")
+ info = {}
+ for t in fields:
+ if not t.strip():
+ continue
+ k, v = t.split("=")
+ info[k] = v
+
+ restkb = int(info["tskb"])
+ maxtraffic = int(info["rapids"])/14 * (5*1024*1024) + restkb
+ tmp = {"validuntil":int(info["billeduntil"]), "trafficleft":maxtraffic if int(info["autorefill"]) else restkb, "maxtraffic":maxtraffic}
+
+ return tmp
def login(self, user, data):
- req = self.core.requestFactory.getRequest(self.__name__, user)
+ req = self.getAccountRequest(user)
api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi"
api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": user, "password": data["password"], "withcookie": 1}
src = req.load(api_url_base, cookies=False, get=api_param_prem)
if src.startswith("ERROR"):
- return
+ raise Exception(src)
fields = src.split("\n")
info = {}
for t in fields:
@@ -72,7 +63,7 @@ class RapidshareCom(Account):
continue
k, v = t.split("=")
info[k] = v
- cj = self.core.requestFactory.getCookieJar(self.__name__, user)
+ cj = self.getAccountCookies(user)
cj.setCookie("rapidshare.com", "enc", info["cookie"])
diff --git a/module/plugins/accounts/ShareonlineBiz.py b/module/plugins/accounts/ShareonlineBiz.py
index 2eb78bf43..e7405c659 100644
--- a/module/plugins/accounts/ShareonlineBiz.py
+++ b/module/plugins/accounts/ShareonlineBiz.py
@@ -29,22 +29,17 @@ class ShareonlineBiz(Account):
__author_name__ = ("mkaay")
__author_mail__ = ("mkaay@mkaay.de")
- def getAccountInfo(self, user):
- try:
- req = self.core.requestFactory.getRequest(self.__name__, user)
- src = req.load("http://www.share-online.biz/alpha/lang/set/english")
- validuntil = re.search(r"Account valid till:.*?<span class='.*?'>(.*?)</span>", src, re.S).group(1)
- validuntil = int(mktime(strptime(validuntil, "%m/%d/%Y, %I:%M:%S %p")))
-
- out = Account.getAccountInfo(self, user)
- tmp = {"validuntil":validuntil, "trafficleft":-1}
- out.update(tmp)
- return out
- except:
- return Account.getAccountInfo(self, user)
+ def loadAccountInfo(self, user):
+ req = self.getAccountRequest(user)
+ src = req.load("http://www.share-online.biz/alpha/lang/set/english")
+ validuntil = re.search(r"Account valid till:.*?<span class='.*?'>(.*?)</span>", src, re.S).group(1)
+ validuntil = int(mktime(strptime(validuntil, "%m/%d/%Y, %I:%M:%S %p")))
+
+ tmp = {"validuntil":validuntil, "trafficleft":-1}
+ return tmp
def login(self, user, data):
- req = self.core.requestFactory.getRequest(self.__name__, user)
+ req = self.getAccountRequest(user)
post_vars = {"user": user,
"pass": data["password"],
"l_rememberme":"1"}
diff --git a/module/plugins/accounts/UploadedTo.py b/module/plugins/accounts/UploadedTo.py
index 99141f20a..a783d9154 100644
--- a/module/plugins/accounts/UploadedTo.py
+++ b/module/plugins/accounts/UploadedTo.py
@@ -29,27 +29,17 @@ class UploadedTo(Account):
__author_name__ = ("mkaay")
__author_mail__ = ("mkaay@mkaay.de")
- def getAccountInfo(self, user):
- try:
- data = None
- for account in self.accounts.items():
- if account[0] == user:
- data = account[1]
- if not data:
- raise Exception
- req = self.core.requestFactory.getRequest(self.__name__, user)
- html = req.load("http://uploaded.to/?setlang=en", cookies=True)
- raw_traffic = re.search(r"Traffic left: </span><span class=.*?>(.*?)</span>", html).group(1)
- raw_valid = re.search(r"Valid until: </span> <span class=.*?>(.*?)</span>", html).group(1)
- traffic = int(self.parseTraffic(raw_traffic))
- validuntil = int(mktime(strptime(raw_valid.strip(), "%d-%m-%Y %H:%M")))
- out = Account.getAccountInfo(self, user)
- tmp = {"validuntil":validuntil, "trafficleft":traffic, "maxtraffic":100*1024*1024}
- out.update(tmp)
- return out
- except:
- return Account.getAccountInfo(self, user)
-
+ def loadAccountInfo(self, user):
+ req = self.getAccountRequest(user)
+ html = req.load("http://uploaded.to/?setlang=en", cookies=True)
+ raw_traffic = re.search(r"Traffic left: </span><span class=.*?>(.*?)</span>", html).group(1)
+ raw_valid = re.search(r"Valid until: </span> <span class=.*?>(.*?)</span>", html).group(1)
+ traffic = int(self.parseTraffic(raw_traffic))
+ validuntil = int(mktime(strptime(raw_valid.strip(), "%d-%m-%Y %H:%M")))
+
+ tmp = {"validuntil":validuntil, "trafficleft":traffic, "maxtraffic":100*1024*1024}
+ return tmp
+
def login(self, user, data):
- req = self.core.requestFactory.getRequest(self.__name__, user)
+ req = self.getAccountRequest()
req.load("http://uploaded.to/login", post={ "email" : user, "password" : data["password"]}, cookies=True)