summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks
diff options
context:
space:
mode:
authorGravatar Nils Hesse <nphesse@gmail.com> 2012-11-08 13:06:06 +0100
committerGravatar Nils Hesse <nphesse@gmail.com> 2012-11-08 13:06:06 +0100
commit5cbfd1ebff6845f2824f0086969b733346858d5a (patch)
treeea648d9a1648123c4f7fe5fa87794e07a201817c /module/plugins/hooks
parentupdate plugins - easybytez,filefactory,rusfolder,euroshare (diff)
downloadpyload-5cbfd1ebff6845f2824f0086969b733346858d5a.tar.xz
Added the reload.cc plugin
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r--module/plugins/hooks/ReloadCc.py59
1 files changed, 59 insertions, 0 deletions
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