From f04e77d96c7483cae90f19eb8468557a44fa49e5 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 5 Feb 2012 06:41:43 +0000 Subject: Stop Real-Debrid from returning streaming responses instead of file downloads. --- module/plugins/hoster/RealdebridCom.py | 35 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'module/plugins/hoster/RealdebridCom.py') diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index 3a3ac99b0..5759838e2 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -2,14 +2,16 @@ # -*- coding: utf-8 -*- import re +from time import time from urllib import quote, unquote from random import randrange -from module.utils import encode +from module.utils import encode, parseFileSize +from module.common.json_layer import json_loads from module.plugins.Hoster import Hoster class RealdebridCom(Hoster): - __version__ = "0.41" + __version__ = "0.42" __pattern__ = r"https?://.*real-debrid\..*" __description__ = """Real-Debrid.com hoster plugin""" __config__ = [("https", "bool", _("Enable HTTPS"), False)] @@ -45,28 +47,24 @@ class RealdebridCom(Hoster): 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(encode(pyfile.url), ""), password) + url = "http://real-debrid.com/ajax/unrestrict.php?lang=en&link=%s&password=%s&time=%s" % (quote(encode(pyfile.url), ""), password, int(time()*1000)) page = self.load(url) + data = json_loads(page) - error = re.search(r'(.*)', page) - generation_ok = re.search(r'(.*)', page) - if generation_ok: - page = generation_ok.group(1).strip() + self.logDebug("Returned Data: %s" % data) - if error: - msg = error.group(1).strip() - self.logDebug(page) - if msg == "Your file is unavailable on the hoster.": + if data["error"] != 0: + if data["message"] == "Your file is unavailable on the hoster.": self.offline() + elif data["message"] == "File's hoster is in maintenance. Try again later.": + self.logWarning(data["message"]) + self.tempOffline() else: - self.fail(msg) - elif url == 'error': - self.fail("Your IP is most likely blocked. Please contact RealDebrid support") - elif page == "File's hoster is in maintenance. Try again later.": - self.logWarning(page) - self.tempOffline() + self.logError(page) else: - new_url = page + self.pyfile.name = data["file_name"] + self.pyfile.size = parseFileSize(data["file_size"]) + new_url = data['generated_links'].split('|')[-1] if self.getConfig("https"): new_url = new_url.replace("http://", "https://") @@ -75,7 +73,6 @@ class RealdebridCom(Hoster): self.log.debug("Real-Debrid: New URL: %s" % new_url) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"): #only use when name wasnt already set pyfile.name = self.getFilename(new_url) -- cgit v1.2.3