summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-02 03:42:55 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-02 03:42:55 +0200
commita1b105f5e74df07abeab46a29de16416954fe4b8 (patch)
tree748d33cf67009ed71d96d96af5ab9fa8c1eb1e19 /module/plugins/accounts
parentFix https://github.com/pyload/pyload/issues/1446 (diff)
downloadpyload-a1b105f5e74df07abeab46a29de16416954fe4b8.tar.xz
Small code cosmetics
Diffstat (limited to 'module/plugins/accounts')
-rw-r--r--module/plugins/accounts/AlldebridCom.py4
-rw-r--r--module/plugins/accounts/NoPremiumPl.py52
-rw-r--r--module/plugins/accounts/RapideoPl.py53
-rw-r--r--module/plugins/accounts/RealdebridCom.py4
4 files changed, 57 insertions, 56 deletions
diff --git a/module/plugins/accounts/AlldebridCom.py b/module/plugins/accounts/AlldebridCom.py
index f9c1f2ca6..d09086907 100644
--- a/module/plugins/accounts/AlldebridCom.py
+++ b/module/plugins/accounts/AlldebridCom.py
@@ -2,7 +2,7 @@
import re
import time
-import xml.dom.minidom as dom
+import xml.dom.minidom
from BeautifulSoup import BeautifulSoup
@@ -43,7 +43,7 @@ class AlldebridCom(Account):
self.logDebug(html)
- xml = dom.parseString(html)
+ xml = xml.dom.minidom.parseString(html)
exp_time = time.time() + int(xml.getElementsByTagName("date")[0].childNodes[0].nodeValue) * 24 * 60 * 60
account_info = {"validuntil": exp_time, "trafficleft": -1}
diff --git a/module/plugins/accounts/NoPremiumPl.py b/module/plugins/accounts/NoPremiumPl.py
index 7e3f757d3..6c034b31f 100644
--- a/module/plugins/accounts/NoPremiumPl.py
+++ b/module/plugins/accounts/NoPremiumPl.py
@@ -4,37 +4,37 @@ import datetime
import hashlib
import time
+from module.common.json_layer import json_loads
from module.plugins.Account import Account
-from module.common.json_layer import json_loads as loads
class NoPremiumPl(Account):
- __name__ = "NoPremiumPl"
+ __name__ = "NoPremiumPl"
+ __type__ = "account"
__version__ = "0.01"
- __type__ = "account"
+
__description__ = "NoPremium.pl account plugin"
- __license__ = "GPLv3"
- __authors__ = [("goddie", "dev@nopremium.pl")]
+ __license__ = "GPLv3"
+ __authors__ = [("goddie", "dev@nopremium.pl")]
- _api_url = "http://crypt.nopremium.pl"
- _api_query = {
- "site": "nopremium",
- "username": "",
- "password": "",
- "output": "json",
- "loc": "1",
- "info": "1"
- }
+ API_URL = "http://crypt.nopremium.pl"
+ API_QUERY = {'site' : "nopremium",
+ 'username': "" ,
+ 'password': "" ,
+ 'output' : "json" ,
+ 'loc' : "1" ,
+ 'info' : "1" }
_req = None
_usr = None
_pwd = None
+
def loadAccountInfo(self, name, req):
self._req = req
try:
- result = loads(self.runAuthQuery())
+ result = json_loads(self.runAuthQuery())
except Exception:
# todo: return or let it be thrown?
return
@@ -45,13 +45,13 @@ class NoPremiumPl(Account):
if "expire" in result.keys() and result["expire"]:
premium = True
valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result["expire"])).timetuple())
+
traffic_left = result["balance"] * 1024
- return ({
- "validuntil": valid_untill,
- "trafficleft": traffic_left,
- "premium": premium
- })
+ return {'validuntil' : valid_untill,
+ 'trafficleft': traffic_left,
+ 'premium' : premium }
+
def login(self, user, data, req):
self._usr = user
@@ -59,23 +59,23 @@ class NoPremiumPl(Account):
self._req = req
try:
- response = loads(self.runAuthQuery())
+ response = json_loads(self.runAuthQuery())
except Exception:
self.wrongPassword()
if "errno" in response.keys():
self.wrongPassword()
+
data['usr'] = self._usr
data['pwd'] = self._pwd
+
def createAuthQuery(self):
- query = self._api_query
+ query = self.API_QUERY
query["username"] = self._usr
query["password"] = self._pwd
-
return query
- def runAuthQuery(self):
- data = self._req.load(self._api_url, post=self.createAuthQuery())
- return data \ No newline at end of file
+ def runAuthQuery(self):
+ return self._req.load(self.API_URL, post=self.createAuthQuery())
diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py
index 3e9d52fe8..92736cba0 100644
--- a/module/plugins/accounts/RapideoPl.py
+++ b/module/plugins/accounts/RapideoPl.py
@@ -4,77 +4,78 @@ import datetime
import hashlib
import time
+from module.common.json_layer import json_loads
from module.plugins.Account import Account
-from module.common.json_layer import json_loads as loads
class RapideoPl(Account):
- __name__ = "RapideoPl"
+ __name__ = "RapideoPl"
+ __type__ = "account"
__version__ = "0.01"
- __type__ = "account"
+
__description__ = "Rapideo.pl account plugin"
- __license__ = "GPLv3"
- __authors__ = [("goddie", "dev@rapideo.pl")]
+ __license__ = "GPLv3"
+ __authors__ = [("goddie", "dev@rapideo.pl")]
- _api_url = "http://enc.rapideo.pl"
- _api_query = {
- "site": "newrd",
- "username": "",
- "password": "",
- "output": "json",
- "loc": "1",
- "info": "1"
- }
+ API_URL = "http://enc.rapideo.pl"
+ API_QUERY = {'site' : "newrd",
+ 'username': "" ,
+ 'password': "" ,
+ 'output' : "json" ,
+ 'loc' : "1" ,
+ 'info' : "1" }
_req = None
_usr = None
_pwd = None
+
def loadAccountInfo(self, name, req):
self._req = req
try:
- result = loads(self.runAuthQuery())
+ result = json_loads(self.runAuthQuery())
except Exception:
# todo: return or let it be thrown?
return
premium = False
valid_untill = -1
+
if "expire" in result.keys() and result["expire"]:
premium = True
valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result["expire"])).timetuple())
traffic_left = result["balance"]
- return ({
- "validuntil": valid_untill,
- "trafficleft": traffic_left,
- "premium": premium
- })
+ return {'validuntil' : valid_untill,
+ 'trafficleft': traffic_left,
+ 'premium' : premium }
+
def login(self, user, data, req):
self._usr = user
self._pwd = hashlib.md5(data["password"]).hexdigest()
self._req = req
+
try:
- response = loads(self.runAuthQuery())
+ response = json_loads(self.runAuthQuery())
except Exception:
self.wrongPassword()
if "errno" in response.keys():
self.wrongPassword()
+
data['usr'] = self._usr
data['pwd'] = self._pwd
+
def createAuthQuery(self):
- query = self._api_query
+ query = self.API_QUERY
query["username"] = self._usr
query["password"] = self._pwd
-
return query
- def runAuthQuery(self):
- data = self._req.load(self._api_url, post=self.createAuthQuery())
- return data \ No newline at end of file
+ def runAuthQuery(self):
+ return self._req.load(self.API_URL, post=self.createAuthQuery())
diff --git a/module/plugins/accounts/RealdebridCom.py b/module/plugins/accounts/RealdebridCom.py
index 41d8a0975..ad2975aa9 100644
--- a/module/plugins/accounts/RealdebridCom.py
+++ b/module/plugins/accounts/RealdebridCom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-import xml.dom.minidom as dom
+import xml.dom.minidom
from module.plugins.Account import Account
@@ -19,7 +19,7 @@ class RealdebridCom(Account):
if self.pin_code:
return {"premium": False}
html = req.load("https://real-debrid.com/api/account.php")
- xml = dom.parseString(html)
+ xml = xml.dom.minidom.parseString(html)
account_info = {"validuntil": float(xml.getElementsByTagName("expiration")[0].childNodes[0].nodeValue),
"trafficleft": -1}