diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-01-03 22:13:18 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-01-03 22:13:18 +0100 |
commit | 5f8de1193343d162963d167aa1f26e411e882a4a (patch) | |
tree | 5051b38c81d36884f670ab27efa021d8e0e68947 | |
parent | Merge pull request #1005 from marley2013/patch-6 (diff) | |
download | pyload-5f8de1193343d162963d167aa1f26e411e882a4a.tar.xz |
[OverLoadMe] Code cosmetics
-rw-r--r-- | module/plugins/accounts/OverLoadMe.py | 23 | ||||
-rw-r--r-- | module/plugins/hoster/OverLoadMe.py | 20 |
2 files changed, 24 insertions, 19 deletions
diff --git a/module/plugins/accounts/OverLoadMe.py b/module/plugins/accounts/OverLoadMe.py index e06fc2023..1fb2a2a10 100644 --- a/module/plugins/accounts/OverLoadMe.py +++ b/module/plugins/accounts/OverLoadMe.py @@ -7,7 +7,7 @@ from module.common.json_layer import json_loads class OverLoadMe(Account): __name__ = "OverLoadMe" __type__ = "account" - __version__ = "0.02" + __version__ = "0.03" __description__ = """Over-Load.me account plugin""" __license__ = "GPLv3" @@ -15,23 +15,28 @@ class OverLoadMe(Account): def loadAccountInfo(self, user, req): - data = self.getAccountData(user) https = "https" if self.getConfig("https") else "http" - html = req.load(https + "://api.over-load.me/account.php", get={"user": user, "auth": data['password']}).strip() + data = self.getAccountData(user) + html = req.load(https + "://api.over-load.me/account.php", + get={'user': user, + 'auth': data['password']}).strip() + data = json_loads(html) + self.logDebug(data) # Check for premium if data['membership'] == "Free": - return {"premium": False} - - account_info = {"validuntil": data['expirationunix'], "trafficleft": -1} - return account_info + return {'premium': False, 'validuntil': None, 'trafficleft': None} + else: + return {'premium': True, 'validuntil': data['expirationunix'], 'trafficleft': -1} def login(self, user, data, req): - https = "https" if self.getConfig("https") else "http" + https = "https" if self.getConfig("https") else "http" jsondata = req.load(https + "://api.over-load.me/account.php", - get={"user": user, "auth": data['password']}).strip() + get={'user': user, + 'auth': data['password']}).strip() + data = json_loads(jsondata) if data['err'] == 1: diff --git a/module/plugins/hoster/OverLoadMe.py b/module/plugins/hoster/OverLoadMe.py index 7cd439e15..cb6bb98ac 100644 --- a/module/plugins/hoster/OverLoadMe.py +++ b/module/plugins/hoster/OverLoadMe.py @@ -27,8 +27,10 @@ class OverLoadMe(MultiHoster): name = unquote(url.rsplit("/", 1)[1]) except IndexError: name = "Unknown_Filename..." + if name.endswith("..."): #: incomplete filename, append random stuff name += "%s.tmp" % randrange(100, 999) + return name @@ -37,13 +39,14 @@ class OverLoadMe(MultiHoster): def handlePremium(self): - data = self.account.getAccountData(self.user) https = "https" if self.getConfig("https") else "http" - page = self.load(https + "://api.over-load.me/getdownload.php", - get={"auth": data['password'], "link": self.pyfile.url}) - data = json_loads(page) + data = self.account.getAccountData(self.user) + page = self.load(https + "://api.over-load.me/getdownload.php", + get={'auth': data['password'], + 'link': self.pyfile.url}) - self.logDebug("Returned Data: %s" % data) + data = json_loads(page) + self.logDebug(data) if data['error'] == 1: self.logWarning(data['msg']) @@ -52,12 +55,9 @@ class OverLoadMe(MultiHoster): if self.pyfile.name is not None and self.pyfile.name.endswith('.tmp') and data['filename']: self.pyfile.name = data['filename'] self.pyfile.size = parseFileSize(data['filesize']) - self.link = data['downloadlink'] - if self.getConfig("https"): - self.link = self.link.replace("http://", "https://") - else: - self.link = self.link.replace("https://", "http://") + http_repl = ["http://", "https://"] + self.link = data['downloadlink'].replace(*http_repl if self.getConfig("https") else *http_repl[::-1]) if self.link != self.pyfile.url: self.logDebug("New URL: %s" % self.link) |