From 2404538888ced4e6964df55823d0514b1c0ba685 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 8 Jul 2014 20:03:27 +0200 Subject: rapideo.pl files added --- module/plugins/hoster/RapideoPl.py | 132 +++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 module/plugins/hoster/RapideoPl.py (limited to 'module/plugins/hoster/RapideoPl.py') 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. +""" + +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) -- cgit v1.2.3 From ea1cbeda0006bbf427223686892c9e6f87cfbe94 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 8 Jul 2014 21:36:14 +0200 Subject: remove redundant author information --- module/plugins/hoster/RapideoPl.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index 4d497faa9..4f23bc4a9 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -1,10 +1,6 @@ # !/usr/bin/env python # -*- coding: utf-8 -*- -""" -@author: Pawel W. -""" - try: from json import loads, dumps except ImportError: -- cgit v1.2.3 From 2ed13d51ab8cd28f2f3db4caabde9b6d2e2cec25 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 11:55:23 +0200 Subject: remove enviroment line --- module/plugins/hoster/RapideoPl.py | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index 4f23bc4a9..b7deaa8ed 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -1,4 +1,3 @@ -# !/usr/bin/env python # -*- coding: utf-8 -*- try: @@ -10,11 +9,9 @@ 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") @@ -31,28 +28,20 @@ class RapideoPl(SimpleHoster): _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": @@ -60,7 +49,6 @@ class RapideoPl(SimpleHoster): query['loc'] = 1 self.logDebug(query) - return self.load(self._api_url, post=query) def process(self, pyfile): -- cgit v1.2.3 From 2e8ed2bf0b357e907f6921c7bb88719bb347367b Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 13:47:49 +0200 Subject: remove blank lines and unused imports --- module/plugins/hoster/RapideoPl.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index b7deaa8ed..587b00bca 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -52,9 +52,7 @@ class RapideoPl(SimpleHoster): 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: -- cgit v1.2.3 From 25d2cceff065a0268a7e183449ef54edf98f1783 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 13:49:12 +0200 Subject: simplify json loads, replace crypto with hashlib --- module/plugins/hoster/RapideoPl.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index 587b00bca..d64919ae0 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -try: - from json import loads, dumps -except ImportError: - from simplejson import loads - +from module.common.json_layer import json_loads as loads from module.plugins.internal.SimpleHoster import SimpleHoster -- cgit v1.2.3 From 4ef0c28e60efa92b0113c748afe5383e7cf432fd Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 14:04:16 +0200 Subject: fail messages localization and dictionary --- module/plugins/hoster/RapideoPl.py | 44 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index d64919ae0..1047b1002 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -20,6 +20,16 @@ class RapideoPl(SimpleHoster): "password": "", "url": ""} + _error_codes = { + 0: "[%s] Incorrect login credentials", + 1: "[%s] Not enough transfer to download - top-up your account", + 2: "[%s] Incorrect / dead link", + 3: "[%s] Error connecting to hosting, try again later", + 9: "[%s] Premium account has expired", + 15: "[%s] Hosting no longer supported", + 80: "[%s] Too many incorrect login attempts, account blocked for 24h" + } + _usr = False _pwd = False @@ -29,7 +39,7 @@ class RapideoPl(SimpleHoster): def get_username_password(self): if not self.account: - self.fail("[Rapideo.pl] Login to Rapideo.pl plugin or turn plugin off") + self.fail(_("Please enter your %s account or deactivate this plugin") % "Rapideo.pl") else: self._usr = self.account.getAccountData(self.user).get('usr') self._pwd = self.account.getAccountData(self.user).get('pwd') @@ -64,39 +74,21 @@ class RapideoPl(SimpleHoster): 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") - + if parsed["errno"] in self._error_codes: + # error code in known + self.fail(self._error_codes[parsed["errno"]] % self.__name__) else: + # error code isn't yet added to plugin self.fail( parsed["errstring"] - or "Unknown error (code: {})".format(parsed["errno"]) + or "Unknown error (code: %s)" % 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"])) + "Download from %s is possible only using Rapideo.pl webiste \ + directly. Update this plugin." % parsed["hosting"]) pyfile.name = parsed["filename"] pyfile.size = parsed["filesize"] -- cgit v1.2.3 From 1e90f0a46b7fd0f1d9376ea966e1650afa782c37 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 16 Sep 2014 23:20:17 +0200 Subject: fix to work with python 2.5 --- module/plugins/hoster/RapideoPl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index 1047b1002..0c46c0593 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -61,14 +61,14 @@ class RapideoPl(SimpleHoster): self.get_username_password() try: data = self.runFileQuery(pyfile.url, 'fileinfo') - except Exception as e: - self.logDebug(str(e)) + except Exception: + self.logDebug("RunFileQuery error") self.tempOffline() try: parsed = loads(data) - except Exception as e: - self.logDebug(str(e)) + except Exception: + self.logDebug("Loads error") self.tempOffline() self.logDebug(parsed) @@ -95,8 +95,8 @@ class RapideoPl(SimpleHoster): try: result_dl = self.runFileQuery(pyfile.url, 'filedownload') - except Exception as e: - self.logDebug(str(e)) + except Exception: + self.logDebug("runFileQuery error #2") self.tempOffline() self.download(result_dl, disposition=True) -- cgit v1.2.3 From 005710831caa04bbe372b54ac357658963fe02bb Mon Sep 17 00:00:00 2001 From: synweap15 Date: Mon, 3 Nov 2014 14:44:44 +0100 Subject: New __authors__ key, added __license__ --- module/plugins/hoster/RapideoPl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index 0c46c0593..9fd20e69e 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -9,8 +9,8 @@ class RapideoPl(SimpleHoster): __version__ = "0.01" __type__ = "hoster" __description__ = "Rapideo.pl hoster plugin" - __author_name__ = ("goddie") - __author_mail__ = ("dev@rapideo.pl") + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@rapideo.pl")] _api_url = "http://enc.rapideo.pl" -- cgit v1.2.3 From 7979d0833573a107baae8c45330b8b5874630a76 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 4 Jan 2015 20:26:13 +0100 Subject: Spare code improvements --- module/plugins/hoster/RapideoPl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index 9fd20e69e..7260ebbe3 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -41,8 +41,9 @@ class RapideoPl(SimpleHoster): if not self.account: self.fail(_("Please enter your %s account or deactivate this plugin") % "Rapideo.pl") else: - self._usr = self.account.getAccountData(self.user).get('usr') - self._pwd = self.account.getAccountData(self.user).get('pwd') + data = self.account.getAccountData(self.user) + self._usr = data['usr'] + self._pwd = data['pwd'] def runFileQuery(self, url, mode=None): query = self._api_query.copy() -- cgit v1.2.3 From fd105f8e51768ec1943cda2375bdfdbe5b0a3951 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 9 Jan 2015 00:35:51 +0100 Subject: "New Year" Update: hoster plugins --- module/plugins/hoster/RapideoPl.py | 116 ++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 58 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index 7260ebbe3..2f7365e3b 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -1,73 +1,74 @@ # -*- coding: utf-8 -*- -from module.common.json_layer import json_loads as loads -from module.plugins.internal.SimpleHoster import SimpleHoster - - -class RapideoPl(SimpleHoster): - __name__ = "RapideoPl" - __version__ = "0.01" - __type__ = "hoster" - __description__ = "Rapideo.pl hoster plugin" - __license__ = "GPLv3" - __authors__ = [("goddie", "dev@rapideo.pl")] - - _api_url = "http://enc.rapideo.pl" - - _api_query = {"site": "newrd", - "output": "json", - "username": "", - "password": "", - "url": ""} - - _error_codes = { - 0: "[%s] Incorrect login credentials", - 1: "[%s] Not enough transfer to download - top-up your account", - 2: "[%s] Incorrect / dead link", - 3: "[%s] Error connecting to hosting, try again later", - 9: "[%s] Premium account has expired", - 15: "[%s] Hosting no longer supported", - 80: "[%s] Too many incorrect login attempts, account blocked for 24h" - } - - _usr = False - _pwd = False - - def setup(self): - self.resumeDownload = True - self.multiDL = True - - def get_username_password(self): - if not self.account: - self.fail(_("Please enter your %s account or deactivate this plugin") % "Rapideo.pl") - else: - data = self.account.getAccountData(self.user) - self._usr = data['usr'] - self._pwd = data['pwd'] +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHoster import MultiHoster + + +class RapideoPl(MultiHoster): + __name__ = "RapideoPl" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'^unmatchable$' + + __description__ = """Rapideo.pl multi-hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@rapideo.pl")] + + + API_URL = "http://enc.rapideo.pl" + + API_QUERY = {'site' : "newrd", + 'output' : "json", + 'username': "", + 'password': "", + 'url' : ""} + + ERROR_CODES = {0 : "[%s] Incorrect login credentials", + 1 : "[%s] Not enough transfer to download - top-up your account", + 2 : "[%s] Incorrect / dead link", + 3 : "[%s] Error connecting to hosting, try again later", + 9 : "[%s] Premium account has expired", + 15: "[%s] Hosting no longer supported", + 80: "[%s] Too many incorrect login attempts, account blocked for 24h"} + + + def prepare(self): + super(RapideoPl, self).prepare() + + data = self.account.getAccountData(self.user) + + self.usr = data['usr'] + self.pwd = data['pwd'] + def runFileQuery(self, url, mode=None): - query = self._api_query.copy() - query["username"] = self._usr - query["password"] = self._pwd - query["url"] = url + 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 + query['loc'] = 1 self.logDebug(query) - return self.load(self._api_url, post=query) - def process(self, pyfile): - self.get_username_password() + return self.load(self.API_URL, post=query) + + + def handleFree(self, pyfile): try: data = self.runFileQuery(pyfile.url, 'fileinfo') + except Exception: self.logDebug("RunFileQuery error") self.tempOffline() try: - parsed = loads(data) + parsed = json_loads(data) + except Exception: self.logDebug("Loads error") self.tempOffline() @@ -75,9 +76,9 @@ class RapideoPl(SimpleHoster): self.logDebug(parsed) if "errno" in parsed.keys(): - if parsed["errno"] in self._error_codes: + if parsed["errno"] in self.ERROR_CODES: # error code in known - self.fail(self._error_codes[parsed["errno"]] % self.__name__) + self.fail(self.ERROR_CODES[parsed["errno"]] % self.__name__) else: # error code isn't yet added to plugin self.fail( @@ -95,9 +96,8 @@ class RapideoPl(SimpleHoster): pyfile.size = parsed["filesize"] try: - result_dl = self.runFileQuery(pyfile.url, 'filedownload') + self.link = self.runFileQuery(pyfile.url, 'filedownload') + except Exception: self.logDebug("runFileQuery error #2") self.tempOffline() - - self.download(result_dl, disposition=True) -- cgit v1.2.3 From cf4ded052964047de88d676045329b8fa4fca2dc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 22 Jan 2015 21:31:19 +0100 Subject: Update plugins after CaptchaService changes --- module/plugins/hoster/RapideoPl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/RapideoPl.py') diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index 2f7365e3b..85591f51f 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -83,14 +83,14 @@ class RapideoPl(MultiHoster): # error code isn't yet added to plugin self.fail( parsed["errstring"] - or "Unknown error (code: %s)" % parsed["errno"] + or _("Unknown error (code: %s)") % parsed["errno"] ) if "sdownload" in parsed: if parsed["sdownload"] == "1": self.fail( - "Download from %s is possible only using Rapideo.pl webiste \ - directly. Update this plugin." % parsed["hosting"]) + _("Download from %s is possible only using Rapideo.pl website \ + directly") % parsed["hosting"]) pyfile.name = parsed["filename"] pyfile.size = parsed["filesize"] -- cgit v1.2.3