diff options
Diffstat (limited to 'module/plugins/hoster/RealdebridCom.py')
-rw-r--r-- | module/plugins/hoster/RealdebridCom.py | 78 |
1 files changed, 37 insertions, 41 deletions
diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index cc6dd49c3..7feacee28 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -7,11 +7,11 @@ from urllib import quote, unquote from time import time from module.common.json_layer import json_loads -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.utils import parseFileSize -class RealdebridCom(Hoster): +class RealdebridCom(SimpleHoster): __name__ = "RealdebridCom" __type__ = "hoster" __version__ = "0.53" @@ -34,61 +34,57 @@ class RealdebridCom(Hoster): def setup(self): - self.chunkLimit = 3 + self.chunkLimit = 3 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "Real-debrid") - self.fail(_("No Real-debrid account provided")) + def handleMulti(self): + password = self.getPassword().splitlines() + if not password: + password = "" else: - self.logDebug("Old URL: %s" % pyfile.url) - password = self.getPassword().splitlines() - if not password: - password = "" - else: - password = password[0] - - data = json_loads(self.load("https://real-debrid.com/ajax/unrestrict.php", - get={'lang' : "en", - 'link' : quote(pyfile.url, ""), - 'password': password, - 'time' : int(time() * 1000)})) - - self.logDebug("Returned Data: %s" % data) - - if data['error'] != 0: - if data['message'] == "Your file is unavailable on the hoster.": - self.offline() - else: - self.logWarning(data['message']) - self.tempOffline() + password = password[0] + + data = json_loads(self.load("https://real-debrid.com/ajax/unrestrict.php", + get={'lang' : "en", + 'link' : quote(self.pyfile.url, ""), + 'password': password, + 'time' : int(time() * 1000)})) + + self.logDebug("Returned Data: %s" % data) + + if data['error'] != 0: + if data['message'] == "Your file is unavailable on the hoster.": + self.offline() else: - if pyfile.name is not None and pyfile.name.endswith('.tmp') and data['file_name']: - pyfile.name = data['file_name'] - pyfile.size = parseFileSize(data['file_size']) - new_url = data['generated_links'][0][-1] + self.logWarning(data['message']) + self.tempOffline() + else: + if self.pyfile.name is not None and self.pyfile.name.endswith('.tmp') and data['file_name']: + self.pyfile.name = data['file_name'] + self.pyfile.size = parseFileSize(data['file_size']) + self.link = data['generated_links'][0][-1] if self.getConfig("https"): - new_url = new_url.replace("http://", "https://") + self.link = self.link.replace("http://", "https://") else: - new_url = new_url.replace("https://", "http://") + self.link = self.link.replace("https://", "http://") - if new_url != pyfile.url: - self.logDebug("New URL: %s" % new_url) + if self.link != self.pyfile.url: + self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown") or pyfile.name.endswith('..'): + if self.pyfile.name.startswith("http") or self.pyfile.name.startswith("Unknown") or self.pyfile.name.endswith('..'): #only use when name wasnt already set - pyfile.name = self.getFilename(new_url) + self.pyfile.name = self.getFilename(self.link) - self.download(new_url, disposition=True) + def checkFile(self): check = self.checkDownload( {"error": "<title>An error occured while processing your request</title>"}) if check == "error": #usual this download can safely be retried self.retry(wait_time=60, reason=_("An error occured while generating link")) + + +getInfo = create_getInfo(RealdebridCom) |