diff options
-rw-r--r-- | module/plugins/accounts/RapideoPl.py | 102 | ||||
-rw-r--r-- | module/plugins/hooks/RapideoPl.py | 38 | ||||
-rw-r--r-- | module/plugins/hoster/RapideoPl.py | 132 |
3 files changed, 272 insertions, 0 deletions
diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py new file mode 100644 index 000000000..f7343cf02 --- /dev/null +++ b/module/plugins/accounts/RapideoPl.py @@ -0,0 +1,102 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@author: Pawel W. <dev@rapideo.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 RapideoPl(Account): + __name__ = "RapideoPl" + __version__ = "0.01" + __type__ = "account" + __description__ = "Rapideo.pl account plugin" + __author_name__ = ("goddie") + __author_mail__ = ("dev@rapideo.pl") + + _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()) + 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"] + + return ({ + "validuntil": valid_untill, + "trafficleft": traffic_left, + "premium": premium + }) + + def login(self, user, data, req): + + self._usr = user + self._pwd = crypto.md5(data["password"]).hexdigest() + + self._req = req + + try: + response = loads(self.runAuthQuery()) + except: + self.wrongPassword() + + if "errno" in response.keys(): + self.wrongPassword() + + data['usr'] = user + data['pwd'] = crypto.md5(data['password']).hexdigest() + + 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/RapideoPl.py b/module/plugins/hooks/RapideoPl.py new file mode 100644 index 000000000..5d7673826 --- /dev/null +++ b/module/plugins/hooks/RapideoPl.py @@ -0,0 +1,38 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@author: Pawel W. <dev@rapideo.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 RapideoPl(MultiHoster): + __name__ = "RapideoPl" + __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__ = "Rapideo.pl hook" + __author_name__ = ("goddie") + __author_mail__ = ("dev@rapideo.pl") + + def getHoster(self): + + hostings = loads(getURL("https://www.rapideo.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/RapideoPl.py b/module/plugins/hoster/RapideoPl.py new file mode 100644 index 000000000..4d497faa9 --- /dev/null +++ b/module/plugins/hoster/RapideoPl.py @@ -0,0 +1,132 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@author: Pawel W. <dev@rapideo.pl> +""" + +try: + from json import loads, dumps +except ImportError: + from simplejson import loads + +from module.plugins.internal.SimpleHoster import SimpleHoster + + +class RapideoPl(SimpleHoster): + + __name__ = "RapideoPl" + __version__ = "0.01" + __type__ = "hoster" + + __description__ = "Rapideo.pl hoster plugin" + __author_name__ = ("goddie") + __author_mail__ = ("dev@rapideo.pl") + + _api_url = "http://enc.rapideo.pl" + + _api_query = {"site": "newrd", + "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("[Rapideo.pl] Login to Rapideo.pl plugin or turn plugin off") + + 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("[Rapideo.pl] Invalid account credentials") + + elif parsed["errno"] == 80: + self.fail("[Rapideo.pl] Too much incorrect login attempts, account blocked for 24h") + + elif parsed["errno"] == 1: + self.fail("[Rapideo.pl] Not enough transfer - top up to download") + + elif parsed["errno"] == 9: + self.fail("[Rapideo.pl] Account expired") + + elif parsed["errno"] == 2: + self.fail("[Rapideo.pl] Invalid / dead link") + + elif parsed["errno"] == 3: + self.fail("[Rapideo.pl] Error connecting to host") + + elif parsed["errno"] == 15: + self.fail("[Rapideo.pl] Hosting no longer supported") + + else: + self.fail( + parsed["errstring"] + or "Unknown error (code: {})".format(parsed["errno"]) + ) + + if "sdownload" in parsed: + if parsed["sdownload"] == "1": + self.fail( + "Download from {} is possible only when using \ + Rapideo.pl directly. Update this plugin.".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) |