diff options
author | synweap15 <shamdog+github@gmail.com> | 2014-07-08 20:00:23 +0200 |
---|---|---|
committer | synweap15 <shamdog+github@gmail.com> | 2014-07-08 20:00:23 +0200 |
commit | 7a7e3e211e36af06d00e0effbcc37ac59e152427 (patch) | |
tree | 4464a5720e6664cb8c8f18077df989e53710ca01 /module/plugins | |
parent | [Oboom] new hoster and account (diff) | |
download | pyload-7a7e3e211e36af06d00e0effbcc37ac59e152427.tar.xz |
nopremium.pl files added
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/accounts/NoPremiumPl.py | 102 | ||||
-rw-r--r-- | module/plugins/hooks/NoPremiumPl.py | 39 | ||||
-rw-r--r-- | module/plugins/hoster/NoPremiumPl.py | 132 |
3 files changed, 273 insertions, 0 deletions
diff --git a/module/plugins/accounts/NoPremiumPl.py b/module/plugins/accounts/NoPremiumPl.py new file mode 100644 index 000000000..e44a6acff --- /dev/null +++ b/module/plugins/accounts/NoPremiumPl.py @@ -0,0 +1,102 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@author: Pawel W. <dev@nopremium.pl> +""" + +from datetime import datetime + +from module.plugins.Account import Account +from module.plugins.internal.SimpleHoster import parseHtmlForm +import re +from time import mktime, strptime +import module.lib.beaker.crypto as crypto + +try: + from json import loads +except ImportError: + from simplejson import loads + +class NoPremiumPl(Account): + __name__ = "NoPremiumPl" + __version__ = "0.01" + __type__ = "account" + __description__ = "NoPremium.pl account plugin" + __author_name__ = ("goddie") + __author_mail__ = ("dev@nopremium.pl") + + _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()) + except: + #todo: ret? + return + + premium = False + valid_untill = -1 + + is_premium = "expire" in result.keys() and result["expire"] is not None + + if is_premium: + + premium = True + valid_untill = mktime(datetime.fromtimestamp(int(result["expire"])).timetuple()) + + traffic_left = result["balance"] * 1024 + + return ({ + "validuntil": valid_untill, + "trafficleft": traffic_left, + "premium": premium + }) + + def login(self, user, data, req): + + self._usr = user + self._pwd = crypto.sha1(crypto.md5(data["password"]).hexdigest()).hexdigest() + + self._req = req + + try: + response = loads(self.runAuthQuery()) + except: + 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["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 diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py new file mode 100644 index 000000000..154d748f1 --- /dev/null +++ b/module/plugins/hooks/NoPremiumPl.py @@ -0,0 +1,39 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@author: Pawel W. <dev@nopremium.pl> +""" + +from module.plugins.internal.MultiHoster import MultiHoster +from module.network.RequestFactory import getURL + +try: + from json import loads +except ImportError: + from simplejson import loads + +class NoPremiumPl(MultiHoster): + __name__ = "NoPremiumPl" + __version__ = "0.01" + __type__ = "hook" + + __config__ = [("activated", "bool", "Activated", "False"), + ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("hosterList", "str", "Hoster list (comma separated)", ""), + ("unloadFailing", "bool", "Try standard download if download fails", "False"), + ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", "24")] + + __description__ = "NoPremium.pl hook" + __author_name__ = ("goddie") + __author_mail__ = ("dev@nopremium.pl") + + def getHoster(self): + + hostings = loads(getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) + return [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] + + def getHosterCached(self): + return self.getHoster() + + diff --git a/module/plugins/hoster/NoPremiumPl.py b/module/plugins/hoster/NoPremiumPl.py new file mode 100644 index 000000000..7f61261b9 --- /dev/null +++ b/module/plugins/hoster/NoPremiumPl.py @@ -0,0 +1,132 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@author: Pawel W. <dev@nopremium.pl> +""" + +try: + from json import loads, dumps +except ImportError: + from simplejson import loads + +from module.plugins.internal.SimpleHoster import SimpleHoster + + +class NoPremiumPl(SimpleHoster): + + __name__ = "NoPremiumPl" + __version__ = "0.01" + __type__ = "hoster" + + __description__ = "NoPremium.pl hoster plugin" + __author_name__ = ("goddie") + __author_mail__ = ("dev@nopremium.pl") + + _api_url = "http://crypt.nopremium.pl" + + _api_query = {"site": "nopremium", + "output": "json", + "username": "", + "password": "", + "url": ""} + + _usr = False + _pwd = False + + def setup(self): + + self.resumeDownload = True + self.multiDL = True + + def get_username_password(self): + + if not self.account: + + self.fail("[NoPremium.pl] Zaloguj się we wtyczce NoPremium.pl lub ją wyłącz") + + else: + + self._usr = self.account.getAccountData(self.user).get('usr') + self._pwd = self.account.getAccountData(self.user).get('pwd') + + def runFileQuery(self, url, mode=None): + + query = self._api_query.copy() + + query["username"] = self._usr + query["password"] = self._pwd + + query["url"] = url + + if mode == "fileinfo": + query['check'] = 2 + query['loc'] = 1 + + self.logDebug(query) + + return self.load(self._api_url, post=query) + + def process(self, pyfile): + + self.get_username_password() + + try: + data = self.runFileQuery(pyfile.url, 'fileinfo') + except Exception as e: + self.logDebug(str(e)) + self.tempOffline() + + try: + parsed = loads(data) + except Exception as e: + self.logDebug(str(e)) + self.tempOffline() + + self.logDebug(parsed) + + if "errno" in parsed.keys(): + + if parsed["errno"] == 0: + self.fail("[NoPremium.pl] Niepoprawne dane logowania") + + elif parsed["errno"] == 80: + self.fail("[NoPremium.pl] Zbyt dużo niepoprawnych logowań, konto zablokowane na 24h") + + elif parsed["errno"] == 1: + self.fail("[NoPremium.pl] Za mało transferu - doładuj aby pobrać") + + elif parsed["errno"] == 9: + self.fail("[NoPremium.pl] Konto wygasło") + + elif parsed["errno"] == 2: + self.fail("[NoPremium.pl] Niepoprawny / wygasły link") + + elif parsed["errno"] == 3: + self.fail("[NoPremium.pl] Błąd łączenia z hostingiem") + + elif parsed["errno"] == 15: + self.fail("[NoPremium.pl] Hosting nie jest już wspierany") + + else: + self.fail( + parsed["errstring"] + or "Nieznany błąd (kod: {})".format(parsed["errno"]) + ) + + if "sdownload" in parsed: + if parsed["sdownload"] == "1": + self.fail( + "Pobieranie z {} jest możliwe tylko przy bezpośrednim użyciu \ + NoPremium.pl. Zaktualizuj wtyczkę.".format(parsed["hosting"])) + + pyfile.name = parsed["filename"] + pyfile.size = parsed["filesize"] + + try: + result_dl = self.runFileQuery(pyfile.url, 'filedownload') + except Exception as e: + self.logDebug(str(e)) + self.tempOffline() + + self.download(result_dl, disposition=True) |