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 | |
parent | store cli config per user (diff) | |
download | pyload-ada420db11c99d1b0758bc8ef9b14b25ff0e16e1.tar.xz |
RealdebridCom plugin
Diffstat (limited to 'module')
-rw-r--r-- | module/HookManager.py | 21 | ||||
-rw-r--r-- | module/PluginThread.py | 2 | ||||
-rw-r--r-- | module/PyFile.py | 2 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 4 | ||||
-rw-r--r-- | module/plugins/PluginManager.py | 24 | ||||
-rw-r--r-- | module/plugins/accounts/RealdebridCom.py | 25 | ||||
-rw-r--r-- | module/plugins/hooks/HotFolder.py | 2 | ||||
-rw-r--r-- | module/plugins/hooks/RealdebridCom.py | 72 | ||||
-rw-r--r-- | module/plugins/hoster/FileserveCom.py | 2 | ||||
-rw-r--r-- | module/plugins/hoster/RealdebridCom.py | 72 |
10 files changed, 217 insertions, 9 deletions
diff --git a/module/HookManager.py b/module/HookManager.py index 1138a4c29..9688d8c60 100644 --- a/module/HookManager.py +++ b/module/HookManager.py @@ -82,6 +82,11 @@ class HookManager: def createIndex(self): plugins = [] + + active = [] + deactive = [] + unloaded = [] + for pluginClass in self.core.pluginManager.getHookPlugins(): try: #hookClass = getattr(plugin, plugin.__name__) @@ -90,12 +95,24 @@ class HookManager: plugin = pluginClass(self.core) plugins.append(plugin) self.pluginMap[pluginClass.__name__] = plugin - self.log.info(_("%(name)s loaded, activated %(value)s") % {"name": pluginClass.__name__, "value": plugin.isActivated() }) + if plugin.isActivated(): + active.append(pluginClass.__name__) + else: + deactive.append(pluginClass.__name__) + + #self.log.info(_("%(name)s loaded, activated %(value)s") % {"name": pluginClass.__name__, "value": plugin.isActivated() }) + else: + #never reached, see plugin manager + unloaded.append(pluginClass.__name__) except: self.log.warning(_("Failed activating %(name)s") % {"name":pluginClass.__name__}) if self.core.debug: traceback.print_exc() + self.log.info(_("Activated plugins: %s") % ", ".join(active)) + self.log.info(_("Deactivate plugins: %s") % ", ".join(deactive)) + #self.log.info(_("Not loaded plugins: %s") % ", ".join(unloaded)) + self.plugins = plugins @@ -112,7 +129,7 @@ class HookManager: self.core.scheduler.addJob(plugin.interval, wrapPeriodical, args=[plugin], threaded=False) for plugin in self.plugins: - if plugin.isActivated(): + if plugin.isActivated() and plugin.interval >= 1: self.core.scheduler.addJob(0, wrapPeriodical, args=[plugin], threaded=False) diff --git a/module/PluginThread.py b/module/PluginThread.py index 3a6483f95..7f967f989 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -433,7 +433,7 @@ class InfoThread(PluginThread): plugins[plugin] = [url] for pluginname, urls in plugins.iteritems(): - plugin = self.m.core.pluginManager.getPlugin(pluginname) + plugin = self.m.core.pluginManager.getPlugin(pluginname, True) if hasattr(plugin, "getInfo"): try: self.m.core.log.debug("Run Info Fetching for %s" % pluginname) diff --git a/module/PyFile.py b/module/PyFile.py index 931975305..0b5dc48be 100644 --- a/module/PyFile.py +++ b/module/PyFile.py @@ -89,7 +89,7 @@ class PyFile(object): """ inits plugin instance """ if not self.plugin: self.pluginmodule = self.m.core.pluginManager.getPlugin(self.pluginname) - self.pluginclass = getattr(self.pluginmodule, self.pluginname) + self.pluginclass = getattr(self.pluginmodule, self.m.core.pluginManager.getPluginName(self.pluginname)) self.plugin = self.pluginclass(self) diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index dcf141dd4..c2e1c3044 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -436,7 +436,9 @@ class Plugin(object): def getPassword(self): - return self.pyfile.package().password + password = self.pyfile.package().password + if not password: return "" + return password def checkForSameFiles(self): diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py index 0ca060152..9f59cb1de 100644 --- a/module/plugins/PluginManager.py +++ b/module/plugins/PluginManager.py @@ -213,7 +213,7 @@ class PluginManager(): return res - def getPlugin(self, name): + def getPlugin(self, name, original=False): """return plugin module from hoster|decrypter|container""" plugin = None @@ -224,6 +224,9 @@ class PluginManager(): if self.hosterPlugins.has_key(name): plugin = self.hosterPlugins[name] + if plugin.has_key("new_module") and not original: + return plugin["new_module"] + if plugin.has_key("module"): return plugin["module"] @@ -231,6 +234,22 @@ class PluginManager(): return plugin["module"] + def getPluginName(self, name): + """ used to obtain new name if other plugin was injected""" + plugin = None + if self.containerPlugins.has_key(name): + plugin = self.containerPlugins[name] + if self.crypterPlugins.has_key(name): + plugin = self.crypterPlugins[name] + if self.hosterPlugins.has_key(name): + plugin = self.hosterPlugins[name] + + if plugin.has_key("new_name"): + return plugin["new_name"] + + return plugin["name"] + + def getCaptchaPlugin(self, name): """return captcha modul if existent""" @@ -285,6 +304,9 @@ class PluginManager(): if not self.core.config.getPlugin(name, "load"): continue except: + if self.core.debug: + print_exc() + self.log.debug("Failed to load %s" % name) continue diff --git a/module/plugins/accounts/RealdebridCom.py b/module/plugins/accounts/RealdebridCom.py new file mode 100644 index 000000000..3137987a9 --- /dev/null +++ b/module/plugins/accounts/RealdebridCom.py @@ -0,0 +1,25 @@ +from module.plugins.Account import Account
+import xml.dom.minidom as dom
+
+class RealdebridCom(Account):
+ __name__ = "RealdebridCom"
+ __version__ = "0.4"
+ __type__ = "account"
+ __description__ = """Real-Debrid.com account plugin"""
+ __author_name__ = ("Devirex, Hazzard")
+ __author_mail__ = ("naibaf_11@yahoo.de")
+
+ def loadAccountInfo(self, user, req):
+ page = req.load("http://real-debrid.com/api/account.php")
+ xml = dom.parseString(page)
+ account_info = {"validuntil": int(xml.getElementsByTagName("expiration")[0].childNodes[0].nodeValue),
+ "trafficleft": -1}
+
+ return account_info
+
+ def login(self, user, data, req):
+ page = req.load("https://real-debrid.com/ajax/login.php?user=%s&pass=%s" % (user, data["password"]))
+ #page = req.load("https://real-debrid.com/login.html", post={"user": user, "pass": data["password"]}, cookies=True)
+
+ if "Your login informations are incorrect" in page:
+ self.wrongPassword()
diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index e652179ce..1e320b87c 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -73,7 +73,7 @@ class HotFolder(Hook): for f in listdir(self.getConfig("folder")): path = join(self.getConfig("folder"), f) - if not isfile(path) or f.endswith("~") or f.startswith("#"): + if not isfile(path) or f.endswith("~") or f.startswith("#") or f.startswith("."): continue newpath = join(self.getConfig("folder"), "finished", f if self.getConfig("keep") else "tmp_"+f) diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py new file mode 100644 index 000000000..e42ab42af --- /dev/null +++ b/module/plugins/hooks/RealdebridCom.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +import re + +from module.network.RequestFactory import getURL +from module.plugins.Hook import Hook + +from module.utils import removeChars + +class RealdebridCom(Hook): + __name__ = "RealdebridCom" + __version__ = "0.4" + __type__ = "hook" + + __config__ = [("activated", "bool", "Activated", "False"), + ("https", "bool", "Enable HTTPS", "False")] + + __description__ = """Real-Debrid.com hook plugin""" + __author_name__ = ("Devirex, Hazzard") + __author_mail__ = ("naibaf_11@yahoo.de") + + interval = 0 + hosters = [] + + replacements = [("freakshare.net", "freakshare.com")] + + def getHostersCached(self): + if not self.hosters: + https = "https" if self.getConfig("https") else "http" + page = getURL(https + "://real-debrid.com/api/hosters.php") + + self.hosters = [x.strip() for x in page.replace("\"", "").split(",")] + + for rep in self.replacements: + if rep[0] in self.hosters: + self.hosters.remove(rep[0]) + self.hosters.append(rep[1]) + + return self.hosters + + def coreReady(self): + pluginMap = {} + for name in self.core.pluginManager.hosterPlugins.keys(): + pluginMap[name.lower()] = name + + supported = [] + new_supported = [] + + for hoster in self.getHostersCached(): + name = removeChars(hoster.lower(), "-.") + + if pluginMap.has_key(name): + supported.append(pluginMap[name]) + else: + new_supported.append(hoster) + + module = self.core.pluginManager.getPlugin("RealdebridCom") + klass = getattr(module, "RealdebridCom") + #inject real debrid plugin + self.core.log.debug("Real-Debrid: Supported Hosters: %s" % ", ".join(sorted(supported))) + for hoster in supported: + dict = self.core.pluginManager.hosterPlugins[hoster] + dict["new_module"] = module + dict["new_name"] = "RealdebridCom" + + self.core.log.debug("Real-Debrid: New Hosters: %s" % ", ".join(sorted(new_supported))) + + #create new regexp + regexp = r".*(%s).*" % "|".join([klass.__pattern__] + [x.replace(".", "\\.") for x in new_supported]) + + dict = self.core.pluginManager.hosterPlugins["RealdebridCom"] + dict["pattern"] = regexp + dict["re"] = re.compile(regexp) diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index 0ab97a4c7..075d48eaf 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -3,8 +3,6 @@ from __future__ import with_statement import re
-from os import remove
-
from module.plugins.Hoster import Hoster
from module.plugins.ReCaptcha import ReCaptcha
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.")
+
|