summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/hoster/RealdebridCom.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 21:59:10 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 21:59:10 +0100
commit8e7d14bae4d3c836f029a1235eb227380acc3f75 (patch)
treeebd0679642cccb994e70a89a106b394189cb28bc /pyload/plugin/hoster/RealdebridCom.py
parentMerge branch 'stable' into 0.4.10 (diff)
downloadpyload-8e7d14bae4d3c836f029a1235eb227380acc3f75.tar.xz
Fix plugins to work on 0.4.10
Diffstat (limited to 'pyload/plugin/hoster/RealdebridCom.py')
-rw-r--r--pyload/plugin/hoster/RealdebridCom.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/pyload/plugin/hoster/RealdebridCom.py b/pyload/plugin/hoster/RealdebridCom.py
new file mode 100644
index 000000000..ae6f69d7c
--- /dev/null
+++ b/pyload/plugin/hoster/RealdebridCom.py
@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+
+import re
+
+from random import randrange
+from urllib import unquote
+from time import time
+
+from pyload.utils import json_loads
+from pyload.plugin.internal.MultiHoster import MultiHoster
+from pyload.utils import parseFileSize
+
+
+class RealdebridCom(MultiHoster):
+ __name__ = "RealdebridCom"
+ __type__ = "hoster"
+ __version__ = "0.64"
+
+ __pattern__ = r'https?://((?:www\.|s\d+\.)?real-debrid\.com/dl/|[\w^_]\.rdb\.so/d/)[\w^_]+'
+
+ __description__ = """Real-Debrid.com multi-hoster plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("Devirex Hazzard", "naibaf_11@yahoo.de")]
+
+
+ def getFilename(self, url):
+ try:
+ name = unquote(url.rsplit("/", 1)[1])
+ except IndexError:
+ name = "Unknown_Filename..."
+ if not name or name.endswith(".."): #: incomplete filename, append random stuff
+ name += "%s.tmp" % randrange(100, 999)
+ return name
+
+
+ def setup(self):
+ self.chunkLimit = 3
+
+
+ def handlePremium(self, pyfile):
+ data = json_loads(self.load("https://real-debrid.com/ajax/unrestrict.php",
+ get={'lang' : "en",
+ 'link' : pyfile.url,
+ 'password': self.getPassword(),
+ '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()
+ 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'])
+ self.link = data['generated_links'][0][-1]
+
+ if self.getConfig("ssl"):
+ self.link = self.link.replace("http://", "https://")
+ else:
+ self.link = self.link.replace("https://", "http://")
+
+ if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown") or pyfile.name.endswith('..'):
+ #only use when name wasnt already set
+ pyfile.name = self.getFilename(self.link)
+
+
+ def checkFile(self):
+ if self.checkDownload({"error": "<title>An error occured while processing your request</title>"}):
+ #usual this download can safely be retried
+ self.retry(wait_time=60, reason=_("An error occured while generating link"))
+
+ return super(RealdebridCom, self).checkFile()