From b65c4091d5c5e793d8a9df17a46657d45c3a1292 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Mon, 24 Sep 2012 23:54:50 +0200 Subject: multihosters - closed #618, store http/ftp accounts, add uptobox.com premium --- module/plugins/internal/MultiHoster.py | 111 +++++++++++++++++++++++---------- module/plugins/internal/XFSPAccount.py | 2 +- 2 files changed, 79 insertions(+), 34 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index e9e321c06..0f25eb8d2 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -11,32 +11,54 @@ class MultiHoster(Hook): Generic MultiHoster plugin """ - __version__ = "0.12" + __version__ = "0.15" interval = 0 hosters = [] - replacements = [] + 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"), + ("ul.to","uploaded.to"), ("uploaded.net","uploaded.to")] supported = [] ignored = [] + new_supported = [] def getHosterCached(self): if not self.hosters: try: - self.hosters = [x.strip() for x in self.getHoster()] - self.hosters = filter(lambda x: x and x not in self.ignored, self.hosters) + hosterSet = self.toHosterSet(self.getHoster()) - set(self.ignored) except Exception, e: self.logError("%s" % str(e)) return [] - - for rep in self.replacements: - if rep[0] in self.hosters: - self.hosters.remove(rep[0]) - if rep[1] not in self.hosters: - self.hosters.append(rep[1]) + + try: + configMode = self.getConfig('hosterListMode') + if configMode in ("listed", "unlisted"): + configSet = self.toHosterSet(self.getConfig('hosterList').replace('|',',').replace(';',',').split(',')) + + if configMode == "listed": + hosterSet &= configSet + else: + hosterSet -= configSet + + except Exception, e: + self.logError("%s" % str(e)) + + self.hosters = list(hosterSet) return self.hosters - + + def toHosterSet(self, hosters): + hosters = set((x.strip().lower() for x in hosters)) + + for rep in self.replacements: + if rep[0] in hosters: + hosters.remove(rep[0]) + hosters.add(rep[1]) + + hosters.discard(u'') + return hosters def getHoster(self): """Load list of supported hoster @@ -49,23 +71,29 @@ class MultiHoster(Hook): pluginMap = {} for name in self.core.pluginManager.hosterPlugins.keys(): pluginMap[name.lower()] = name - - new_supported = [] + + accountList = [ name.lower() for name, data in self.core.accountManager.accounts.items() if data ] + excludedList = [] for hoster in self.getHosterCached(): name = remove_chars(hoster.lower(), "-.") - if name in pluginMap: - self.supported.append(pluginMap[name]) + if name in accountList: + excludedList.append(hoster) else: - new_supported.append(hoster) + if name in pluginMap: + self.supported.append(pluginMap[name]) + else: + self.new_supported.append(hoster) - if not self.supported and not new_supported: + if not self.supported and not self.new_supported: self.logError(_("No Hoster loaded")) return 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))) @@ -73,25 +101,42 @@ class MultiHoster(Hook): dict = self.core.pluginManager.hosterPlugins[hoster] dict["new_module"] = module dict["new_name"] = self.__name__ + + if excludedList: + self.logInfo("The following hosters were not overwritten - account exists: %s" % ", ".join(sorted(excludedList))) + + if self.new_supported: + 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])) + self.logDebug("Regexp: %s" % regexp) + + dict = self.core.pluginManager.hosterPlugins[self.__name__] + dict["pattern"] = regexp + dict["re"] = re.compile(regexp) - self.logDebug("New Hosters: %s" % ", ".join(sorted(new_supported))) - - # create new regexp - if not klass.__pattern__: - regexp = r".*(%s).*" % "|".join([x.replace(".", "\\.") for x in new_supported]) - else: - regexp = r".*(%s).*" % "|".join([klass.__pattern__] + [x.replace(".", "\\.") for x in new_supported]) - 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] + self.logDebug(dict) + if "module" in dict: + del dict["module"] + if "new_module" in dict: + del dict["new_module"] + del dict["new_name"] def unload(self): for hoster in self.supported: - dict = self.core.pluginManager.hosterPlugins[hoster] - if "module" in dict: - del dict["module"] - - del dict["new_module"] - del dict["new_name"] + self.unloadHoster(hoster) + + def downloadFailed(self, pyfile): + 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__: + self.unloadHoster(pyfile.pluginname) + pyfile.setStatus("queued") \ No newline at end of file diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index ad25ad2c8..8333c7265 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -33,7 +33,7 @@ class XFSPAccount(Account): MAIN_PAGE = None - VALID_UNTIL_PATTERN = r'>Premium account expire:([^<]+)' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:([^<]+)' TRAFFIC_LEFT_PATTERN = r'>Traffic available today:([^<]+)' def loadAccountInfo(self, user, req): -- cgit v1.2.3 From 233bf90feb2941ecacee56966fdee2cd2f65d7b2 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Tue, 25 Sep 2012 19:07:51 +0200 Subject: small plugin fixes --- module/plugins/internal/MultiHoster.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 0f25eb8d2..044bc3423 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -14,14 +14,16 @@ class MultiHoster(Hook): __version__ = "0.15" interval = 0 - hosters = [] 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"), + ("hellshare.com", "hellshare.cz"), ("share-rapid.cz","sharerapid.com"), ("sharerapid.cz","sharerapid.com"), ("ul.to","uploaded.to"), ("uploaded.net","uploaded.to")] - supported = [] ignored = [] - new_supported = [] + + def setup(self): + self.hosters = [] + self.supported = [] + self.new_supported = [] def getHosterCached(self): if not self.hosters: @@ -74,7 +76,7 @@ class MultiHoster(Hook): accountList = [ name.lower() for name, data in self.core.accountManager.accounts.items() if data ] excludedList = [] - + for hoster in self.getHosterCached(): name = remove_chars(hoster.lower(), "-.") @@ -112,7 +114,7 @@ class MultiHoster(Hook): 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|.*(%s).*" % (klass.__pattern__, "|".join([x.replace(".", "\\.") for x in self.new_supported])) self.logDebug("Regexp: %s" % regexp) dict = self.core.pluginManager.hosterPlugins[self.__name__] -- cgit v1.2.3 From 80527abdc69f3fb4c5cf5518b215594146cde0f5 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Sun, 30 Sep 2012 18:44:20 +0200 Subject: filebeer folder crypter, multihoster unload fix --- module/plugins/internal/MultiHoster.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 044bc3423..04353dcc8 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -11,7 +11,7 @@ class MultiHoster(Hook): Generic MultiHoster plugin """ - __version__ = "0.15" + __version__ = "0.16" interval = 0 replacements = [("2shared.com", "twoshared.com"), ("4shared.com", "fourshared.com"), ("cloudnator.com", "shragle.com"), @@ -124,7 +124,6 @@ class MultiHoster(Hook): def unloadHoster(self, hoster): dict = self.core.pluginManager.hosterPlugins[hoster] - self.logDebug(dict) if "module" in dict: del dict["module"] @@ -137,8 +136,10 @@ class MultiHoster(Hook): self.unloadHoster(hoster) def downloadFailed(self, pyfile): - 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__: - self.unloadHoster(pyfile.pluginname) - pyfile.setStatus("queued") \ No newline at end of file + """remove plugin override if download fails but not if file is offline/temp.offline""" + if pyfile.hasStatus("failed"): + 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__: + self.unloadHoster(pyfile.pluginname) + pyfile.setStatus("queued") \ No newline at end of file -- cgit v1.2.3 From a3ecb6eaa2b449c15ce6367e21b3744401e5ab18 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Mon, 1 Oct 2012 23:52:18 +0200 Subject: rapidgator.net premium, novafile.com free, multihoster schedule refresh --- module/plugins/internal/CaptchaService.py | 79 +++++++++++++++++++++++++++++++ module/plugins/internal/MultiHoster.py | 73 +++++++++++++++++++++------- 2 files changed, 135 insertions(+), 17 deletions(-) create mode 100644 module/plugins/internal/CaptchaService.py (limited to 'module/plugins/internal') 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 . + + @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 -- cgit v1.2.3 From 9216dc73ee645ec9c64b376a982024c4e4a92e71 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 2 Oct 2012 15:48:52 +0200 Subject: little multihoster fix --- module/plugins/internal/MultiHoster.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index e6dc621b0..f35f35c5c 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -11,7 +11,7 @@ class MultiHoster(Hook): Generic MultiHoster plugin """ - __version__ = "0.17" + __version__ = "0.18" 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"), @@ -141,7 +141,7 @@ class MultiHoster(Hook): # create new regexp regexp = r".*(%s).*" % "|".join([x.replace(".", "\\.") for x in self.new_supported]) - if hasattr(klass, "__pattern__") and '://' in klass.__pattern__: + if hasattr(klass, "__pattern__") and isinstance(klass.__pattern__, basestring) and '://' in klass.__pattern__: regexp = r"%s|%s" % (klass.__pattern__, regexp) self.logDebug("Regexp: %s" % regexp) @@ -181,4 +181,4 @@ class MultiHoster(Hook): 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 + pyfile.setStatus("queued") -- cgit v1.2.3 From 5658d5525d5088a6254322210c1641cbdba2eb7d Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Wed, 3 Oct 2012 01:14:48 +0200 Subject: update czshare, little fixes --- module/plugins/internal/CaptchaService.py | 2 +- module/plugins/internal/MultiHoster.py | 47 +++++++++++++++++-------------- 2 files changed, 27 insertions(+), 22 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 8be442d37..f2de00732 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -18,7 +18,7 @@ import re -class CaptchaService() +class CaptchaService(): __version__ = "0.01" def __init__(self, plugin): diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index f35f35c5c..a8961aafc 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -11,24 +11,20 @@ class MultiHoster(Hook): Generic MultiHoster plugin """ - __version__ = "0.18" + __version__ = "0.19" 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"), ("1fichier.com", "onefichier.com")] ignored = [] - interval = 24 * 60 * 60 + interval = 24 * 60 * 60 # reload hosters daily 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: @@ -63,14 +59,14 @@ class MultiHoster(Hook): return self.hosters def toHosterSet(self, hosters): - hosters = set((x.strip().lower() for x in hosters)) + hosters = set((str(x).strip().lower() for x in hosters)) for rep in self.replacements: if rep[0] in hosters: hosters.remove(rep[0]) hosters.add(rep[1]) - hosters.discard(u'') + hosters.discard('') return hosters def getHoster(self): @@ -81,14 +77,27 @@ class MultiHoster(Hook): raise NotImplementedError def coreReady(self): - if not self.interval: - if self.cb: - self.core.scheduler.removeJob(self.cb) - self.overridePlugins() + if self.cb: + self.core.scheduler.removeJob(self.cb) + + self.setConfig("activated", True) # config not in sync after plugin reload + + cfg_interval = self.getConfig("interval", None) # reload interval in hours + if cfg_interval is not None: + self.interval = cfg_interval * 60 * 60 + + if self.interval: + self._periodical() + else: + self.periodical() + + def initPeriodical(self): + pass def periodical(self): """reload hoster list periodically""" self.logInfo("Reloading supported hoster list") + old_supported = self.supported self.supported, self.new_supported, self.hosters = [], [], [] @@ -96,9 +105,9 @@ class MultiHoster(Hook): old_supported = [hoster for hoster in old_supported if hoster not in self.supported] if old_supported: - self.logDebug("UNLOAD", old_supported) + self.logDebug("UNLOAD: %s" % ", ".join(old_supported)) for hoster in old_supported: - self.unloadHoster(hoster) + self.unloadHoster(hoster) def overridePlugins(self): pluginMap = {} @@ -160,7 +169,7 @@ class MultiHoster(Hook): del dict["new_name"] def unload(self): - """remove override for all hosters""" + """Remove override for all hosters. Scheduler job is removed by hookmanager""" for hoster in self.supported: self.unloadHoster(hoster) @@ -168,11 +177,7 @@ class MultiHoster(Hook): 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) + dict["re"] = re.compile(dict["pattern"]) def downloadFailed(self, pyfile): """remove plugin override if download fails but not if file is offline/temp.offline""" @@ -181,4 +186,4 @@ class MultiHoster(Hook): 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") + pyfile.setStatus("queued") \ No newline at end of file -- cgit v1.2.3 From 1b494bca9f442b3a8dd75818c68f41235dcdbdfe Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Sat, 20 Oct 2012 09:30:04 +0200 Subject: small plugin fixes, closed #694, #695 --- module/plugins/internal/SimpleHoster.py | 55 ++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 14 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 6d7bb6284..a4a7c5efa 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -42,22 +42,47 @@ def parseHtmlTagAttrValue(attr_name, tag): m = re.search(r"%s\s*=\s*([\"']?)((?<=\")[^\"]+|(?<=')[^']+|[^>\s\"'][^>\s]*)\1" % attr_name, tag, re.I) return m.group(2) if m else None -def parseHtmlForm(attr_str, html): - inputs = {} - action = None - form = re.search(r"(?P]*%s[^>]*>)(?P.*?)]*>" % attr_str, html, re.S | re.I) - if form: +def parseHtmlForm(attr_str, html, input_names=None): + for form in re.finditer(r"(?P]*%s[^>]*>)(?P.*?)]*>" % attr_str, html, re.S | re.I): + inputs = {} action = parseHtmlTagAttrValue("action", form.group('tag')) - for input in re.finditer(r'(<(input|textarea)[^>]*>)([^<]*(?=]*>)([^<]*(?= Date: Thu, 15 Nov 2012 21:25:44 +0100 Subject: update hellshare (now premium only), SimpleHoster.py - utf8-encode url --- module/plugins/internal/SimpleHoster.py | 75 ++++++++++++++++----------------- 1 file changed, 36 insertions(+), 39 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index a4a7c5efa..cfc9f2b43 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -31,17 +31,17 @@ def replace_patterns(string, ruleslist): string = re.sub(rf, rt, string) #self.logDebug(rf, rt, string) return string - + def set_cookies(cj, cookies): for cookie in cookies: if isinstance(cookie, tuple) and len(cookie) == 3: domain, name, value = cookie cj.setCookie(domain, name, value) - + def parseHtmlTagAttrValue(attr_name, tag): - m = re.search(r"%s\s*=\s*([\"']?)((?<=\")[^\"]+|(?<=')[^']+|[^>\s\"'][^>\s]*)\1" % attr_name, tag, re.I) + m = re.search(r"%s\s*=\s*([\"']?)((?<=\")[^\"]+|(?<=')[^']+|[^>\s\"'][^>\s]*)\1" % attr_name, tag, re.I) return m.group(2) if m else None - + def parseHtmlForm(attr_str, html, input_names=None): for form in re.finditer(r"(?P]*%s[^>]*>)(?P.*?)]*>" % attr_str, html, re.S | re.I): inputs = {} @@ -54,50 +54,42 @@ def parseHtmlForm(attr_str, html, input_names=None): inputs[name] = inputtag.group(3) or '' else: inputs[name] = value - + if isinstance(input_names, dict): # check input attributes for key, val in input_names.items(): if key in inputs: if isinstance(val, basestring) and inputs[key] == val: - print "MATCH STRING", val, inputs[key] - continue + continue elif isinstance(val, tuple) and inputs[key] in val: - print "MATCH TUPLE", val, inputs[key] continue elif hasattr(val, "search") and re.match(val, inputs[key]): - print "MATCH REGEXP", val, inputs[key] continue - print "NO MATCH", inputs, input_names break # attibute value does not match else: - print "NO KEY", inputs, input_names break # attibute name does not match - else: - print "ALL MATCH", inputs, input_names - return action, inputs # passed attribute check + else: + return action, inputs # passed attribute check else: - # no attribute check - print "NOCHECK", inputs, input_names, type(input_names) - return action, inputs - - print "NONE", inputs + # no attribute check + return action, inputs + return {}, None # no matching form found -def parseFileInfo(self, url = '', html = ''): +def parseFileInfo(self, url = '', html = ''): info = {"name" : url, "size" : 0, "status" : 3} - - if hasattr(self, "pyfile"): - url = self.pyfile.url + + if hasattr(self, "pyfile"): + url = self.pyfile.url if hasattr(self, "req") and self.req.http.code == '404': info['status'] = 1 else: if not html and hasattr(self, "html"): html = self.html - if isinstance(self.SH_BROKEN_ENCODING, (str, unicode)): + if isinstance(self.SH_BROKEN_ENCODING, (str, unicode)): html = unicode(html, self.SH_BROKEN_ENCODING) if hasattr(self, "html"): self.html = html - + if hasattr(self, "FILE_OFFLINE_PATTERN") and re.search(self.FILE_OFFLINE_PATTERN, html): # File offline info['status'] = 1 @@ -107,7 +99,7 @@ def parseFileInfo(self, url = '', html = ''): info.update(re.match(self.__pattern__, url).groupdict()) except: pass - + for pattern in ("FILE_INFO_PATTERN", "FILE_NAME_PATTERN", "FILE_SIZE_PATTERN"): try: info.update(re.search(getattr(self, pattern), html).groupdict()) @@ -154,7 +146,7 @@ class PluginParseError(Exception): class SimpleHoster(Hoster): __name__ = "SimpleHoster" - __version__ = "0.27" + __version__ = "0.28" __pattern__ = None __type__ = "hoster" __description__ = """Base hoster plugin""" @@ -172,13 +164,13 @@ class SimpleHoster(Hoster): FILE_SIZE_REPLACEMENTS = [] FILE_NAME_REPLACEMENTS = [("&#?\w+;", fixup)] FILE_URL_REPLACEMENTS = [] - + SH_BROKEN_ENCODING = False # Set to True or encoding name if encoding in http header is not correct SH_COOKIES = True # or False or list of tuples [(domain, name, value)] SH_CHECK_TRAFFIC = False # True = force check traffic left for a premium account - + def init(self): - self.file_info = {} + self.file_info = {} def setup(self): self.resumeDownload = self.multiDL = True if self.premium else False @@ -186,6 +178,7 @@ class SimpleHoster(Hoster): def process(self, pyfile): pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) + self.req.setOption("timeout", 120) self.html = self.load(pyfile.url, decode = not self.SH_BROKEN_ENCODING, cookies = self.SH_COOKIES) self.getFileInfo() if self.premium and (not self.SH_CHECK_TRAFFIC or self.checkTrafficLeft()): @@ -193,13 +186,17 @@ class SimpleHoster(Hoster): else: self.handleFree() + def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, decode=False): + if type(url) == unicode: url = url.encode('utf8') + return Hoster.load(self, url=url, get=get, post=post, ref=ref, cookies=cookies, just_header=just_header, decode=decode) + def getFileInfo(self): self.logDebug("URL: %s" % self.pyfile.url) if hasattr(self, "TEMP_OFFLINE_PATTERN") and re.search(self.TEMP_OFFLINE_PATTERN, self.html): self.tempOffline() name, size, status = parseFileInfo(self)[:3] - + if status == 1: self.offline() elif status != 2: @@ -227,28 +224,28 @@ class SimpleHoster(Hoster): def parseError(self, msg): raise PluginParseError(msg) - + def longWait(self, wait_time = None, max_tries = 3): if wait_time and isinstance(wait_time, (int, long, float)): time_str = "%dh %dm" % divmod(wait_time / 60, 60) else: wait_time = 900 time_str = "(unknown time)" - max_tries = 100 - + max_tries = 100 + self.logInfo("Download limit reached, reconnect or wait %s" % time_str) - + self.setWait(wait_time, True) self.wait() - self.retry(max_tries = max_tries, reason="Download limit reached") + self.retry(max_tries = max_tries, reason="Download limit reached") def parseHtmlForm(self, attr_str='', input_names=None): return parseHtmlForm(attr_str, self.html, input_names) - - def checkTrafficLeft(self): + + def checkTrafficLeft(self): traffic = self.account.getAccountInfo(self.user, True)["trafficleft"] if traffic == -1: return True size = self.pyfile.size / 1024 - self.logInfo("Filesize: %i KiB, Traffic left for user %s: %i KiB" % (size, self.user, traffic)) + self.logInfo("Filesize: %i KiB, Traffic left for user %s: %i KiB" % (size, self.user, traffic)) return size <= traffic \ No newline at end of file -- cgit v1.2.3 From 02e6b873ad9971d4974a5b4f7a126dee3da60d2c Mon Sep 17 00:00:00 2001 From: Stefano Date: Thu, 7 Mar 2013 20:17:29 +0100 Subject: SpeedLoadOrgFolder: crypter rewritten Trivial changes to the SimpleCrypter class --- module/plugins/internal/SimpleCrypter.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 69798bc0a..b4f4230a1 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -17,12 +17,12 @@ @author: zoidberg """ -from re import findall +import re from module.plugins.Crypter import Crypter class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" - __version__ = "0.01" + __version__ = "0.02" __pattern__ = None __type__ = "crypter" __description__ = """Base crypter plugin""" @@ -35,10 +35,9 @@ class SimpleCrypter(Crypter): def decrypt(self, pyfile): self.html = self.load(self.url) - new_links = [] - new_links.extend(findall(self.LINK_PATTERN, self.html)) + new_links = re.findall(self.LINK_PATTERN, self.html) if new_links: self.core.files.addLinks(new_links, self.pyfile.package().id) else: - self.fail('Could not extract any links') \ No newline at end of file + self.fail('Could not extract any links') -- cgit v1.2.3 From 37a51ca5616b019737280c915ae2729d40f295fc Mon Sep 17 00:00:00 2001 From: Stefano Date: Thu, 7 Mar 2013 22:07:33 +0100 Subject: SimpleCrypter: improved plugin Added support for package name detection Canonical way to add a package Code cleanup --- module/plugins/internal/SimpleCrypter.py | 44 ++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index b4f4230a1..b8942c724 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - + @author: zoidberg """ @@ -22,22 +22,44 @@ from module.plugins.Crypter import Crypter class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" - __version__ = "0.02" + __version__ = "0.03" __pattern__ = None __type__ = "crypter" __description__ = """Base crypter plugin""" - __author_name__ = ("zoidberg") - __author_mail__ = ("zoidberg@mujmail.cz") + __author_name__ = ("stickell", "zoidberg") + __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz") + """ + These patterns should be defined by each hoster: + + LINK_PATTERN: group(1) must be a download link + example: