From 5cbfd1ebff6845f2824f0086969b733346858d5a Mon Sep 17 00:00:00 2001 From: Nils Hesse Date: Thu, 8 Nov 2012 13:06:06 +0100 Subject: Added the reload.cc plugin --- module/plugins/hoster/ReloadCc.py | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 module/plugins/hoster/ReloadCc.py (limited to 'module/plugins/hoster/ReloadCc.py') diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py new file mode 100644 index 000000000..4195afb89 --- /dev/null +++ b/module/plugins/hoster/ReloadCc.py @@ -0,0 +1,58 @@ +from module.plugins.Hoster import Hoster + +from module.common.json_layer import json_loads + +class ReloadCc(Hoster): + __name__ = "ReloadCc" + __version__ = "0.1" + __type__ = "hoster" + __description__ = """Reload.Cc hoster plugin""" + + # Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady create the regex patterns for us using getHosters in our ReloadCc hook. + __pattern__ = None + + __author_name__ = ("Reload Team") + __author_mail__ = ("hello@reload.cc") + + def process(self, pyfile): + # Check account + if not self.account or not self.account.canUse(): + self.logError(_("Please enter a valid reload.cc account or deactivate this plugin")) + self.fail("No valid reload.cc account provided") + + # In some cases hostsers do not supply us with a filename at download, so we are going to set a fall back filename (e.g. for freakshare or xfileshare) + self.pyfile.name = self.pyfile.name.split('/').pop() # Remove everthing before last slash + + # Correction for automatic assigned filename: Removing html at end if needed + suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] + temp = self.pyfile.name.split('.') + if temp.pop() in suffix_to_remove: + self.pyfile.name = ".".join(temp) + + # Get account data + (user, data) = self.account.selectAccount() + + pwd = "pwd=%s" % data['password'] + + try: + pwd = "hash=%s" % data['pwdhash'] + except Exception: + pass + + # Get rewritten link using the reload.cc api v1 + answer = self.load("https://api.reload.cc/dl?via=pyload&v=1&user=%s&%s&uri=%s" % (user, pwd, self.pyfile.url)) + data = json_loads(answer) + + # Check status and decide what to do + status = data['status'] + if status == "ok": + self.download(data['link'], disposition=True) + # TODO: real error codes/messages + elif status == 400: + self.fail("Invalid link") + elif status == 404: + self.offline() + elif status >= 500: + self.tempOffline() + else: + self.fail(data['msg']) -- cgit v1.2.3 From 676b45df1589ce6bce14999f1753484c4f0d7f53 Mon Sep 17 00:00:00 2001 From: Nils Hesse Date: Thu, 8 Nov 2012 13:17:28 +0100 Subject: Added some error codes to the reload.cc hoster plugin Removed some leftover comments from account plugin --- module/plugins/hoster/ReloadCc.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/ReloadCc.py') diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py index 4195afb89..bec7d2222 100644 --- a/module/plugins/hoster/ReloadCc.py +++ b/module/plugins/hoster/ReloadCc.py @@ -4,7 +4,7 @@ from module.common.json_layer import json_loads class ReloadCc(Hoster): __name__ = "ReloadCc" - __version__ = "0.1" + __version__ = "0.1.1" __type__ = "hoster" __description__ = """Reload.Cc hoster plugin""" @@ -49,9 +49,17 @@ class ReloadCc(Hoster): self.download(data['link'], disposition=True) # TODO: real error codes/messages elif status == 400: - self.fail("Invalid link") - elif status == 404: + self.fail("Unsupported URI") + elif status == 401: + self.fail("Invalid login") + elif status == 402: + self.fail("Payment required") + elif status == 403: + self.fail("User is disabled") + elif status == 404: self.offline() + elif status == 509: + self.fail("Fairuse traffic exceeded") elif status >= 500: self.tempOffline() else: -- cgit v1.2.3 From f9be782bb266b783a00a5bec3ea3d7c7028fc459 Mon Sep 17 00:00:00 2001 From: Nils Hesse Date: Thu, 8 Nov 2012 13:17:51 +0100 Subject: Removed leftover comment from reload.cc hoster account --- module/plugins/hoster/ReloadCc.py | 1 - 1 file changed, 1 deletion(-) (limited to 'module/plugins/hoster/ReloadCc.py') diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py index bec7d2222..36e76226c 100644 --- a/module/plugins/hoster/ReloadCc.py +++ b/module/plugins/hoster/ReloadCc.py @@ -47,7 +47,6 @@ class ReloadCc(Hoster): status = data['status'] if status == "ok": self.download(data['link'], disposition=True) - # TODO: real error codes/messages elif status == 400: self.fail("Unsupported URI") elif status == 401: -- cgit v1.2.3 From a0217bf6ef37f5ee57b2bf04baa6568adb69247a Mon Sep 17 00:00:00 2001 From: Nils Hesse Date: Thu, 8 Nov 2012 23:46:51 +0100 Subject: Use a dictionary to supply HTTP requests with the GET parameters (ensure proper URL encoding) --- module/plugins/hoster/ReloadCc.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'module/plugins/hoster/ReloadCc.py') diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py index 36e76226c..1fb1d4419 100644 --- a/module/plugins/hoster/ReloadCc.py +++ b/module/plugins/hoster/ReloadCc.py @@ -4,7 +4,7 @@ from module.common.json_layer import json_loads class ReloadCc(Hoster): __name__ = "ReloadCc" - __version__ = "0.1.1" + __version__ = "0.2" __type__ = "hoster" __description__ = """Reload.Cc hoster plugin""" @@ -17,7 +17,7 @@ class ReloadCc(Hoster): def process(self, pyfile): # Check account if not self.account or not self.account.canUse(): - self.logError(_("Please enter a valid reload.cc account or deactivate this plugin")) + self.logError("Please enter a valid reload.cc account or deactivate this plugin") self.fail("No valid reload.cc account provided") # In some cases hostsers do not supply us with a filename at download, so we are going to set a fall back filename (e.g. for freakshare or xfileshare) @@ -31,17 +31,22 @@ class ReloadCc(Hoster): # Get account data (user, data) = self.account.selectAccount() - - pwd = "pwd=%s" % data['password'] + + query_params = dict( + via='pyload', + v=1, + user=user, + uri=self.pyfile.url + ) try: - pwd = "hash=%s" % data['pwdhash'] + query_params.update(dict(hash=self.account.infos[user]['pwdhash'])) except Exception: - pass + query_params.update(dict(pwd=data['password'])) # Get rewritten link using the reload.cc api v1 - answer = self.load("https://api.reload.cc/dl?via=pyload&v=1&user=%s&%s&uri=%s" % (user, pwd, self.pyfile.url)) - data = json_loads(answer) + answer = self.load("https://api.reload.cc/dl", get=query_params) + data = json_loads(answer) # Check status and decide what to do status = data['status'] -- cgit v1.2.3 From a0ce4ee20996e7cb13d2379bd2c27459bea6bf7f Mon Sep 17 00:00:00 2001 From: Nils Hesse Date: Wed, 14 Nov 2012 19:23:26 +0100 Subject: Update the error codes --- module/plugins/hoster/ReloadCc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/hoster/ReloadCc.py') diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py index 1fb1d4419..7c171befe 100644 --- a/module/plugins/hoster/ReloadCc.py +++ b/module/plugins/hoster/ReloadCc.py @@ -62,8 +62,10 @@ class ReloadCc(Hoster): self.fail("User is disabled") elif status == 404: self.offline() - elif status == 509: + elif status == 409: self.fail("Fairuse traffic exceeded") + elif status == 428: + self.fail("Hoster currently not possible") elif status >= 500: self.tempOffline() else: -- cgit v1.2.3 From 883371e41d81cc45abd986a50610d04026ed71c6 Mon Sep 17 00:00:00 2001 From: Nils Hesse Date: Wed, 13 Feb 2013 22:09:05 +0100 Subject: Enable better error handling for the Reload.cc plugin --- module/plugins/hoster/ReloadCc.py | 68 +++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 24 deletions(-) (limited to 'module/plugins/hoster/ReloadCc.py') diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py index 7c171befe..a038594dc 100644 --- a/module/plugins/hoster/ReloadCc.py +++ b/module/plugins/hoster/ReloadCc.py @@ -2,15 +2,17 @@ from module.plugins.Hoster import Hoster from module.common.json_layer import json_loads +from module.network.HTTPRequest import BadHeader + class ReloadCc(Hoster): __name__ = "ReloadCc" __version__ = "0.2" __type__ = "hoster" __description__ = """Reload.Cc hoster plugin""" - + # Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady create the regex patterns for us using getHosters in our ReloadCc hook. __pattern__ = None - + __author_name__ = ("Reload Team") __author_mail__ = ("hello@reload.cc") @@ -19,10 +21,10 @@ class ReloadCc(Hoster): if not self.account or not self.account.canUse(): self.logError("Please enter a valid reload.cc account or deactivate this plugin") self.fail("No valid reload.cc account provided") - + # In some cases hostsers do not supply us with a filename at download, so we are going to set a fall back filename (e.g. for freakshare or xfileshare) self.pyfile.name = self.pyfile.name.split('/').pop() # Remove everthing before last slash - + # Correction for automatic assigned filename: Removing html at end if needed suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] temp = self.pyfile.name.split('.') @@ -44,29 +46,47 @@ class ReloadCc(Hoster): except Exception: query_params.update(dict(pwd=data['password'])) - # Get rewritten link using the reload.cc api v1 - answer = self.load("https://api.reload.cc/dl", get=query_params) + try: + answer = self.load("https://api.reload.cc/dl", get=query_params) + except BadHeader as e: + if e.code == 400: + self.fail("The URI is not supported by Reload.cc.") + elif e.code == 401: + self.fail("Wrong username or password") + elif e.code == 402: + self.fail("Your account is inactive. A payment is required for downloading!") + elif e.code == 403: + self.fail("Your account is disabled. Please contact the Reload.cc support!") + elif e.code == 409: + self.logWarning("The hoster seems to be a limited hoster and you've used your daily traffic for this hoster: %s" % self.pyfile.url) + # Wait for 6 hours and retry up to 4 times => one day + self.retry(max_retries=4, wait_time=(3600 * 6), reason="Limited hoster traffic limit exceeded") + elif e.code == 429: + self.retry(max_retries=5, wait_time=120, reason="Too many concurrent connections") # Too many connections, wait 2 minutes and try again + elif e.code == 503: + self.retry(wait_time=600, reason="Reload.cc is currently in maintenance mode! Please check again later.") # Retry in 10 minutes + else: + self.fail("Internal error within Reload.cc. Please contact the Reload.cc support for further information.") + return + data = json_loads(answer) # Check status and decide what to do status = data['status'] if status == "ok": - self.download(data['link'], disposition=True) - elif status == 400: - self.fail("Unsupported URI") - elif status == 401: - self.fail("Invalid login") - elif status == 402: - self.fail("Payment required") - elif status == 403: - self.fail("User is disabled") - elif status == 404: - self.offline() - elif status == 409: - self.fail("Fairuse traffic exceeded") - elif status == 428: - self.fail("Hoster currently not possible") - elif status >= 500: - self.tempOffline() + try: + self.download(data['link'], disposition=True) + except BadHeader as e: + if e.code == 404: + self.fail("File Not Found") + elif e.code == 412: + self.fail("File access password is wrong") + elif e.code == 417: + self.fail("Password required for file access") + elif e.code == 429: + self.retry(max_retries=5, wait_time=120, reason="Too many concurrent connections") # Too many connections, wait 2 minutes and try again + else: + self.fail("Internal error within Reload.cc. Please contact the Reload.cc support for further information.") + return else: - self.fail(data['msg']) + self.fail("Internal error within Reload.cc. Please contact the Reload.cc support for further information.") -- cgit v1.2.3 From 5463da932d15aa2e7551bcc06faee9a810a7950c Mon Sep 17 00:00:00 2001 From: Nils Hesse Date: Wed, 13 Feb 2013 22:46:17 +0100 Subject: Add support for limited connections to the Reload.cc plugin --- module/plugins/hoster/ReloadCc.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'module/plugins/hoster/ReloadCc.py') diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py index a038594dc..d56247868 100644 --- a/module/plugins/hoster/ReloadCc.py +++ b/module/plugins/hoster/ReloadCc.py @@ -72,8 +72,19 @@ class ReloadCc(Hoster): data = json_loads(answer) # Check status and decide what to do - status = data['status'] + status = data.get('status', None) if status == "ok": + conn_limit = data.get('msg', 0) + # API says these connections are limited + # Make sure this limit is used - the download will fail if not + if conn_limit > 0: + try: + self.limitDL = int(conn_limit) + except ValueError: + self.limitDL = 1 + else: + self.limitDL = 0 + try: self.download(data['link'], disposition=True) except BadHeader as e: -- cgit v1.2.3 From 752c9297529a6eca2df50b5a5ef4011388d849dd Mon Sep 17 00:00:00 2001 From: Nils Hesse Date: Wed, 13 Feb 2013 23:09:24 +0100 Subject: Change exception handling to Python 2.5 compatible syntax. Increase version numbers of the plugins. --- module/plugins/hoster/ReloadCc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/ReloadCc.py') diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py index d56247868..6edce3b14 100644 --- a/module/plugins/hoster/ReloadCc.py +++ b/module/plugins/hoster/ReloadCc.py @@ -6,7 +6,7 @@ from module.network.HTTPRequest import BadHeader class ReloadCc(Hoster): __name__ = "ReloadCc" - __version__ = "0.2" + __version__ = "0.3" __type__ = "hoster" __description__ = """Reload.Cc hoster plugin""" @@ -48,7 +48,7 @@ class ReloadCc(Hoster): try: answer = self.load("https://api.reload.cc/dl", get=query_params) - except BadHeader as e: + except BadHeader, e: if e.code == 400: self.fail("The URI is not supported by Reload.cc.") elif e.code == 401: @@ -87,7 +87,7 @@ class ReloadCc(Hoster): try: self.download(data['link'], disposition=True) - except BadHeader as e: + except BadHeader, e: if e.code == 404: self.fail("File Not Found") elif e.code == 412: -- cgit v1.2.3 From c00d44161399f7094931bac8144f544f3dd4002b Mon Sep 17 00:00:00 2001 From: Nils Hesse Date: Fri, 22 Feb 2013 15:20:34 +0100 Subject: Change from https:// to http:// for api.reload.cc requests (SSL not supported yet) --- module/plugins/hoster/ReloadCc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/ReloadCc.py') diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py index 6edce3b14..7dc6d9bb6 100644 --- a/module/plugins/hoster/ReloadCc.py +++ b/module/plugins/hoster/ReloadCc.py @@ -6,7 +6,7 @@ from module.network.HTTPRequest import BadHeader class ReloadCc(Hoster): __name__ = "ReloadCc" - __version__ = "0.3" + __version__ = "0.4" __type__ = "hoster" __description__ = """Reload.Cc hoster plugin""" @@ -47,7 +47,7 @@ class ReloadCc(Hoster): query_params.update(dict(pwd=data['password'])) try: - answer = self.load("https://api.reload.cc/dl", get=query_params) + answer = self.load("http://api.reload.cc/dl", get=query_params) except BadHeader, e: if e.code == 400: self.fail("The URI is not supported by Reload.cc.") -- cgit v1.2.3