diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-05-24 19:48:33 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-05-24 19:48:33 +0200 |
commit | ada420db11c99d1b0758bc8ef9b14b25ff0e16e1 (patch) | |
tree | 63d2bc1cfac22d4f3000c73be21abcaa39d2ff26 /module/plugins/hoster/RealdebridCom.py | |
parent | store cli config per user (diff) | |
download | pyload-ada420db11c99d1b0758bc8ef9b14b25ff0e16e1.tar.xz |
RealdebridCom plugin
Diffstat (limited to 'module/plugins/hoster/RealdebridCom.py')
-rw-r--r-- | module/plugins/hoster/RealdebridCom.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py new file mode 100644 index 000000000..dc5b9098b --- /dev/null +++ b/module/plugins/hoster/RealdebridCom.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+from urllib import quote, unquote
+from module.plugins.Hoster import Hoster
+
+class RealdebridCom(Hoster):
+ __name__ = "RealdebridCom"
+ __version__ = "0.4"
+ __type__ = "hoster"
+
+ __pattern__ = r"https?://.*real-debrid\..*"
+ __description__ = """Real-Debrid.com hoster plugin"""
+ __author_name__ = ("Devirex, Hazzard")
+ __author_mail__ = ("naibaf_11@yahoo.de")
+
+ def getFilename(self, url):
+ return unquote(url.rsplit("/", 1)[1])
+
+ def setup(self):
+ self.chunkLimit = 3
+ self.resumeDownload = True
+
+ def process(self, pyfile):
+ if not self.account:
+ self.log.error(_("Please enter your Real-debrid account"))
+ self.fail("No Real-debrid account provided")
+
+ self.log.debug("Real-Debrid: Old URL: %s" % pyfile.url)
+ if re.match(self.__pattern__, pyfile.url):
+ new_url = pyfile.url
+ else:
+ password = self.getPassword().splitlines()
+ if not password: password = ""
+ else: password = password[0]
+
+ url = "http://real-debrid.com/ajax/deb.php?lang=en&sl=1&link=%s&passwort=%s" % (quote(pyfile.url, ""), password)
+ page = self.load(url)
+
+ error = re.search(r'<span id="generation-error">(.*)</span>', page)
+
+ if error:
+ msg = error.group(1).strip()
+ self.log.debug(page)
+ if msg == "Your file is unavailable on the hoster.":
+ self.offline()
+ else:
+ self.fail(msg)
+ else:
+ new_url = page
+
+ if self.getConfig("https"):
+ new_url = new_url.replace("http://", "https://")
+ else:
+ new_url = new_url.replace("https://", "http://")
+
+ self.log.debug("Real-Debrid: New URL: %s" % new_url)
+
+ try:
+ pyfile.name = self.getFilename(new_url)
+ except IndexError:
+ pyfile.name = "Unknown_Filename.ext"
+
+ self.download(new_url, disposition=True)
+
+ check = self.checkDownload(
+ {"error": "<html><head><title>An error occured while processing your request</title>"})
+
+ if check == "error":
+ self.fail("Error occured.")
+
|