summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster
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/hoster
parentupdate plugins - easybytez,filefactory,rusfolder,euroshare (diff)
downloadpyload-5cbfd1ebff6845f2824f0086969b733346858d5a.tar.xz
Added the reload.cc plugin
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r--module/plugins/hoster/ReloadCc.py58
1 files changed, 58 insertions, 0 deletions
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'])