summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts/PremiumizeMe.py
diff options
context:
space:
mode:
authorGravatar Florian Franzen <FlorianFranzen@gmail.com> 2012-04-09 18:30:54 +0200
committerGravatar Florian Franzen <FlorianFranzen@gmail.com> 2012-04-09 18:30:54 +0200
commit3be8d531ce7c6500170bde8b8dbe49e7dc59ad39 (patch)
treea53ed551df68110ee398945c1a88a5da7cf83b4d /module/plugins/accounts/PremiumizeMe.py
parenticyfiles, bayfiles by godofdream, alldebrid json api, zevera python 2.5 compat. (diff)
downloadpyload-3be8d531ce7c6500170bde8b8dbe49e7dc59ad39.tar.xz
Added premiumize.me support, using their new API (https://secure.premiumize.me/?show=api). This fixes #416.
Diffstat (limited to 'module/plugins/accounts/PremiumizeMe.py')
-rw-r--r--module/plugins/accounts/PremiumizeMe.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/module/plugins/accounts/PremiumizeMe.py b/module/plugins/accounts/PremiumizeMe.py
new file mode 100644
index 000000000..768fcd783
--- /dev/null
+++ b/module/plugins/accounts/PremiumizeMe.py
@@ -0,0 +1,40 @@
+from module.plugins.Account import Account
+
+from module.common.json_layer import json_loads
+
+class PremiumizeMe(Account):
+ __name__ = "PremiumizeMe"
+ __version__ = "0.1"
+ __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)
+
+ # Parse account info
+ account_info = {"validuntil": float(status['result']['expires']),
+ "trafficleft": status['result']['trafficleft_bytes'] / 1024}
+
+ 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']))
+ return json_loads(answer)
+ \ No newline at end of file