summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-10-01 23:52:18 +0200
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-10-01 23:52:18 +0200
commita3ecb6eaa2b449c15ce6367e21b3744401e5ab18 (patch)
tree39a6af87f47f7aa8e0af4f58e1aff00bfce2359e /module/plugins/internal
parentfilebeer folder crypter, multihoster unload fix (diff)
downloadpyload-a3ecb6eaa2b449c15ce6367e21b3744401e5ab18.tar.xz
rapidgator.net premium, novafile.com free, multihoster schedule refresh
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/CaptchaService.py79
-rw-r--r--module/plugins/internal/MultiHoster.py73
2 files changed, 135 insertions, 17 deletions
diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py
new file mode 100644
index 000000000..8be442d37
--- /dev/null
+++ b/module/plugins/internal/CaptchaService.py
@@ -0,0 +1,79 @@
+# -*- coding: utf-8 -*-
+"""
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ @author: zoidberg
+"""
+
+import re
+
+class CaptchaService()
+ __version__ = "0.01"
+
+ def __init__(self, plugin):
+ self.plugin = plugin
+
+class ReCaptcha():
+ def __init__(self, plugin):
+ self.plugin = plugin
+
+ def challenge(self, id):
+ js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k":id}, cookies=True)
+
+ try:
+ challenge = re.search("challenge : '(.*?)',", js).group(1)
+ server = re.search("server : '(.*?)',", js).group(1)
+ except:
+ self.plugin.fail("recaptcha error")
+ result = self.result(server,challenge)
+
+ return challenge, result
+
+ def result(self, server, challenge):
+ return self.plugin.decryptCaptcha("%simage"%server, get={"c":challenge}, cookies=True, forceUser=True, imgtype="jpg")
+
+class AdsCaptcha(CaptchaService):
+ def challenge(self, src):
+ js = self.plugin.req.load(src, cookies=True)
+
+ try:
+ challenge = re.search("challenge: '(.*?)',", js).group(1)
+ server = re.search("server: '(.*?)',", js).group(1)
+ except:
+ self.plugin.fail("adscaptcha error")
+ result = self.result(server,challenge)
+
+ return challenge, result
+
+ def result(self, server, challenge):
+ return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={"cid": challenge, "dummy": random()}, cookies=True, imgtype="jpg")
+
+class SolveMedia(CaptchaService):
+ def __init__(self,plugin):
+ self.plugin = plugin
+
+ def challenge(self, src):
+ html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.script?k=%s" % src, cookies=True)
+ try:
+ ckey = re.search("ckey:.*?'(.*?)',",html).group(1)
+ html = self.plugin.req.load("http://api.solvemedia.com/papi/_challenge.js?k=%s" % ckey, cookies=True)
+ challenge = re.search('"chid".*?: "(.*?)"',html).group(1)
+ except:
+ self.plugin.fail("solvmedia error")
+ result = self.result(challenge)
+
+ return challenge, result
+
+ def result(self,challenge):
+ return self.plugin.decryptCaptcha("http://api.solvemedia.com/papi/media?c=%s" % challenge,imgtype="gif") \ No newline at end of file
diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py
index 04353dcc8..e6dc621b0 100644
--- a/module/plugins/internal/MultiHoster.py
+++ b/module/plugins/internal/MultiHoster.py
@@ -11,19 +11,30 @@ class MultiHoster(Hook):
Generic MultiHoster plugin
"""
- __version__ = "0.16"
+ __version__ = "0.17"
- interval = 0
replacements = [("2shared.com", "twoshared.com"), ("4shared.com", "fourshared.com"), ("cloudnator.com", "shragle.com"),
("ifile.it", "filecloud.io"), ("easy-share.com","crocko.com"), ("freakshare.net","freakshare.com"),
("hellshare.com", "hellshare.cz"), ("share-rapid.cz","sharerapid.com"), ("sharerapid.cz","sharerapid.com"),
- ("ul.to","uploaded.to"), ("uploaded.net","uploaded.to")]
+ ("ul.to","uploaded.to"), ("uploaded.net","uploaded.to"), ("1fichier.com", "onefichier.com")]
ignored = []
+ interval = 24 * 60 * 60
def setup(self):
self.hosters = []
self.supported = []
self.new_supported = []
+
+ cfg_interval = self.getConfig("interval", None) # reload interval in hours
+ if cfg_interval is not None:
+ self.interval = cfg_interval * 60 * 60
+
+ def getConfig(self, option, default = ''):
+ """getConfig with default value - sublass may not implements all config options"""
+ try:
+ return self.getConf(option)
+ except KeyError:
+ return default
def getHosterCached(self):
if not self.hosters:
@@ -35,9 +46,9 @@ class MultiHoster(Hook):
return []
try:
- configMode = self.getConfig('hosterListMode')
+ configMode = self.getConfig('hosterListMode', 'all')
if configMode in ("listed", "unlisted"):
- configSet = self.toHosterSet(self.getConfig('hosterList').replace('|',',').replace(';',',').split(','))
+ configSet = self.toHosterSet(self.getConfig('hosterList', '').replace('|',',').replace(';',',').split(','))
if configMode == "listed":
hosterSet &= configSet
@@ -68,8 +79,28 @@ class MultiHoster(Hook):
:return: List of domain names
"""
raise NotImplementedError
-
+
def coreReady(self):
+ if not self.interval:
+ if self.cb:
+ self.core.scheduler.removeJob(self.cb)
+ self.overridePlugins()
+
+ def periodical(self):
+ """reload hoster list periodically"""
+ self.logInfo("Reloading supported hoster list")
+ old_supported = self.supported
+ self.supported, self.new_supported, self.hosters = [], [], []
+
+ self.overridePlugins()
+
+ old_supported = [hoster for hoster in old_supported if hoster not in self.supported]
+ if old_supported:
+ self.logDebug("UNLOAD", old_supported)
+ for hoster in old_supported:
+ self.unloadHoster(hoster)
+
+ def overridePlugins(self):
pluginMap = {}
for name in self.core.pluginManager.hosterPlugins.keys():
pluginMap[name.lower()] = name
@@ -95,8 +126,6 @@ class MultiHoster(Hook):
module = self.core.pluginManager.getPlugin(self.__name__)
klass = getattr(module, self.__name__)
- print module, klass
-
# inject plugin plugin
self.logDebug("Overwritten Hosters: %s" % ", ".join(sorted(self.supported)))
for hoster in self.supported:
@@ -111,17 +140,16 @@ class MultiHoster(Hook):
self.logDebug("New Hosters: %s" % ", ".join(sorted(self.new_supported)))
# create new regexp
- if not klass.__pattern__:
- regexp = r".*(%s).*" % "|".join([x.replace(".", "\\.") for x in new_supported])
- else:
- regexp = r"%s|.*(%s).*" % (klass.__pattern__, "|".join([x.replace(".", "\\.") for x in self.new_supported]))
+ regexp = r".*(%s).*" % "|".join([x.replace(".", "\\.") for x in self.new_supported])
+ if hasattr(klass, "__pattern__") and '://' in klass.__pattern__:
+ regexp = r"%s|%s" % (klass.__pattern__, regexp)
+
self.logDebug("Regexp: %s" % regexp)
dict = self.core.pluginManager.hosterPlugins[self.__name__]
dict["pattern"] = regexp
dict["re"] = re.compile(regexp)
-
def unloadHoster(self, hoster):
dict = self.core.pluginManager.hosterPlugins[hoster]
if "module" in dict:
@@ -132,14 +160,25 @@ class MultiHoster(Hook):
del dict["new_name"]
def unload(self):
+ """remove override for all hosters"""
for hoster in self.supported:
- self.unloadHoster(hoster)
+ self.unloadHoster(hoster)
+
+ # reset pattern
+ klass = getattr(self.core.pluginManager.getPlugin(self.__name__), self.__name__)
+ dict = self.core.pluginManager.hosterPlugins[self.__name__]
+ dict["pattern"] = getattr(klass, '__pattern__', r"^unmatchable$")
+ dict["re"] = re.compile(dict["pattern"])
+
+ # remove scheduler job
+ if self.cb:
+ self.core.scheduler.removeJob(self.cb)
def downloadFailed(self, pyfile):
"""remove plugin override if download fails but not if file is offline/temp.offline"""
- if pyfile.hasStatus("failed"):
+ if pyfile.hasStatus("failed") and self.getConfig("unloadFailing", True):
hdict = self.core.pluginManager.hosterPlugins[pyfile.pluginname]
- self.logDebug("Unload MultiHoster", pyfile.pluginname, hdict)
- if "new_name" in hdict and hdict['new_name'] == self.__name__:
+ if "new_name" in hdict and hdict['new_name'] == self.__name__:
+ self.logDebug("Unload MultiHoster", pyfile.pluginname, hdict)
self.unloadHoster(pyfile.pluginname)
pyfile.setStatus("queued") \ No newline at end of file