summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/accounts
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-07-12 21:58:37 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-07-12 21:58:37 +0200
commitfdabb02b229f52fd3f98efb678df278eee2a28b6 (patch)
tree6ff1d8a316040e37a1d4667c48c50525c25c0c22 /pyload/plugins/accounts
parentupdated locale, upload task (diff)
downloadpyload-fdabb02b229f52fd3f98efb678df278eee2a28b6.tar.xz
adapted premiumize me
Diffstat (limited to 'pyload/plugins/accounts')
-rw-r--r--pyload/plugins/accounts/PremiumizeMe.py41
1 files changed, 29 insertions, 12 deletions
diff --git a/pyload/plugins/accounts/PremiumizeMe.py b/pyload/plugins/accounts/PremiumizeMe.py
index 696fdf88f..e8c2d277f 100644
--- a/pyload/plugins/accounts/PremiumizeMe.py
+++ b/pyload/plugins/accounts/PremiumizeMe.py
@@ -1,22 +1,22 @@
-from module.plugins.Account import Account
+from pyload.plugins.MultiHoster import MultiHoster
+from pyload.utils import json_loads
-from module.common.json_layer import json_loads
-class PremiumizeMe(Account):
+class PremiumizeMe(MultiHoster):
__name__ = "PremiumizeMe"
__version__ = "0.11"
__type__ = "account"
__description__ = """Premiumize.Me account plugin"""
-
+
__author_name__ = ("Florian Franzen")
__author_mail__ = ("FlorianFranzen@gmail.com")
def loadAccountInfo(self, user, req):
-
+
# Get user data from premiumize.me
status = self.getAccountStatus(user, req)
self.logDebug(status)
-
+
# Parse account info
account_info = {"validuntil": float(status['result']['expires']),
"trafficleft": max(0, status['result']['trafficleft_bytes'] / 1024)}
@@ -27,18 +27,35 @@ class PremiumizeMe(Account):
return account_info
def login(self, user, data, req):
-
+
# Get user data from premiumize.me
status = self.getAccountStatus(user, req)
-
+
# Check if user and password are valid
if status['status'] != 200:
self.wrongPassword()
-
+
def getAccountStatus(self, user, req):
-
+
# Use premiumize.me API v1 (see https://secure.premiumize.me/?show=api) to retrieve account info and return the parsed json answer
- answer = req.load("https://api.premiumize.me/pm-api/v1.php?method=accountstatus&params[login]=%s&params[pass]=%s" % (user, self.accounts[user]['password']))
+ answer = req.load(
+ "https://api.premiumize.me/pm-api/v1.php?method=accountstatus&params[login]=%s&params[pass]=%s" % (
+ user, self.password))
return json_loads(answer)
-
+
+
+ def loadHosterList(self, req):
+
+ # Get supported hosters list from premiumize.me using the json API v1 (see https://secure.premiumize.me/?show=api)
+ answer = req.load(
+ "https://api.premiumize.me/pm-api/v1.php?method=hosterlist&params[login]=%s&params[pass]=%s" % (
+ self.loginname, self.password))
+ data = json_loads(answer)
+
+ # If account is not valid thera are no hosters available
+ if data['status'] != 200:
+ return []
+
+ # Extract hosters from json file
+ return data['result']['hosterlist']