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/hooks/ReloadCc.py | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 module/plugins/hooks/ReloadCc.py (limited to 'module/plugins/hooks/ReloadCc.py') diff --git a/module/plugins/hooks/ReloadCc.py b/module/plugins/hooks/ReloadCc.py new file mode 100644 index 000000000..1d4adfbe3 --- /dev/null +++ b/module/plugins/hooks/ReloadCc.py @@ -0,0 +1,59 @@ +from module.plugins.internal.MultiHoster import MultiHoster + +from module.common.json_layer import json_loads +from module.network.RequestFactory import getURL + +class ReloadCc(MultiHoster): + __name__ = "ReloadCc" + __version__ = "0.1" + __type__ = "hook" + __description__ = """Reload.cc hook plugin""" + + __config__ = [("activated", "bool", "Activated", "False"), + ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("hosterList", "str", "Hoster list (comma separated)", "")] + + __author_name__ = ("Reload Team") + __author_mail__ = ("hello@reload.cc") + + interval = 0 # Disable periodic calls, we dont use them anyway + + def getHoster(self): + # If no accounts are available there will be no hosters available + if not self.account or not self.account.canUse(): + print "ReloadCc: No accounts available" + return [] + + # Get account data + (user, data) = self.account.selectAccount() + + pwd = "pwd=%s" % data['password'] + + try: + pwd = "hash=%s" % data['pwdhash'] + except Exception: + pass + + # Get supported hosters list from reload.cc using the json API v1 + answer = getURL("https://api.reload.cc/login?via=pyload&v=1&get_supported=true&get_traffic=true&user=%s&%s" % (user, pwd)) + data = json_loads(answer) + + + # If account is not valid thera are no hosters available + if data['status'] != "ok": + print "ReloadCc: Status is not ok: %s" % data['status'] + return [] + + # Extract hosters from json file + return data['msg']['supportedHosters'] + + def coreReady(self): + # Get account plugin and check if there is a valid account available + self.account = self.core.accountManager.getAccountPlugin("ReloadCc") + if not self.account.canUse(): + self.account = None + self.logError(_("Please add a valid reload.cc account first and restart pyLoad.")) + return + + # Run the overwriten core ready which actually enables the multihoster hook + return MultiHoster.coreReady(self) \ No newline at end of file -- 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/hooks/ReloadCc.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks/ReloadCc.py') diff --git a/module/plugins/hooks/ReloadCc.py b/module/plugins/hooks/ReloadCc.py index 1d4adfbe3..e563e81ba 100644 --- a/module/plugins/hooks/ReloadCc.py +++ b/module/plugins/hooks/ReloadCc.py @@ -5,7 +5,7 @@ from module.network.RequestFactory import getURL class ReloadCc(MultiHoster): __name__ = "ReloadCc" - __version__ = "0.1" + __version__ = "0.2" __type__ = "hook" __description__ = """Reload.cc hook plugin""" @@ -16,7 +16,7 @@ class ReloadCc(MultiHoster): __author_name__ = ("Reload Team") __author_mail__ = ("hello@reload.cc") - interval = 0 # Disable periodic calls, we dont use them anyway + interval = 0 # Disable periodic calls def getHoster(self): # If no accounts are available there will be no hosters available @@ -26,16 +26,22 @@ class ReloadCc(MultiHoster): # Get account data (user, data) = self.account.selectAccount() - - pwd = "pwd=%s" % data['password'] + + # Get supported hosters list from reload.cc using the json API v1 + query_params = dict( + via='pyload', + v=1, + get_supported='true', + get_traffic='true', + user=user + ) 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 supported hosters list from reload.cc using the json API v1 - answer = getURL("https://api.reload.cc/login?via=pyload&v=1&get_supported=true&get_traffic=true&user=%s&%s" % (user, pwd)) + answer = getURL("https://api.reload.cc/login", get=query_params) data = json_loads(answer) @@ -52,7 +58,7 @@ class ReloadCc(MultiHoster): self.account = self.core.accountManager.getAccountPlugin("ReloadCc") if not self.account.canUse(): self.account = None - self.logError(_("Please add a valid reload.cc account first and restart pyLoad.")) + self.logError("Please add a valid reload.cc account first and restart pyLoad.") return # Run the overwriten core ready which actually enables the multihoster hook -- 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/hooks/ReloadCc.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'module/plugins/hooks/ReloadCc.py') diff --git a/module/plugins/hooks/ReloadCc.py b/module/plugins/hooks/ReloadCc.py index e563e81ba..dbd9d659b 100644 --- a/module/plugins/hooks/ReloadCc.py +++ b/module/plugins/hooks/ReloadCc.py @@ -5,25 +5,25 @@ from module.network.RequestFactory import getURL class ReloadCc(MultiHoster): __name__ = "ReloadCc" - __version__ = "0.2" + __version__ = "0.3" __type__ = "hook" __description__ = """Reload.cc hook plugin""" __config__ = [("activated", "bool", "Activated", "False"), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("hosterList", "str", "Hoster list (comma separated)", "")] __author_name__ = ("Reload Team") __author_mail__ = ("hello@reload.cc") interval = 0 # Disable periodic calls - - def getHoster(self): + + def getHoster(self): # If no accounts are available there will be no hosters available if not self.account or not self.account.canUse(): print "ReloadCc: No accounts available" return [] - + # Get account data (user, data) = self.account.selectAccount() @@ -41,25 +41,25 @@ class ReloadCc(MultiHoster): except Exception: query_params.update(dict(pwd=data['password'])) - answer = getURL("https://api.reload.cc/login", get=query_params) + answer = getURL("http://api.reload.cc/login", get=query_params) data = json_loads(answer) - - + + # If account is not valid thera are no hosters available if data['status'] != "ok": print "ReloadCc: Status is not ok: %s" % data['status'] return [] - - # Extract hosters from json file - return data['msg']['supportedHosters'] - + + # Extract hosters from json file + return data['msg']['supportedHosters'] + def coreReady(self): # Get account plugin and check if there is a valid account available - self.account = self.core.accountManager.getAccountPlugin("ReloadCc") + self.account = self.core.accountManager.getAccountPlugin("ReloadCc") if not self.account.canUse(): self.account = None self.logError("Please add a valid reload.cc account first and restart pyLoad.") return - - # Run the overwriten core ready which actually enables the multihoster hook - return MultiHoster.coreReady(self) \ No newline at end of file + + # Run the overwriten core ready which actually enables the multihoster hook + return MultiHoster.coreReady(self) -- cgit v1.2.3