def run(self): plugins = accumulate(self.data) crypter = {} # db or info result cb = self.updateDB if self.pid > 1 else self.updateResult # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: crypter[name] = plugins[name] del plugins[name] if crypter: # decrypt them links, packages = self.decrypt(crypter, err=True) # push these as initial result and save package names cb(links) for pack in packages: for url in pack.getURLs(): self.names[url] = pack.name links.extend(pack.links) cb(pack.links) # TODO: no plugin information pushed to GUI # parse links and merge hoster, crypter = self.m.core.pluginManager.parseUrls( [l.url for l in links]) accumulate(hoster + crypter, plugins) self.progress = ProgressInfo( "BasePlugin", "", _("online check"), 0, 0, sum(len(urls) for urls in plugins.itervalues()), self.owner, ProgressType.LinkCheck) for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.loadModule("hoster", pluginname) klass = self.m.core.pluginManager.getPluginClass("hoster", pluginname, overwrite=False) if has_method(klass, "getInfo"): self.fetchForPlugin(klass, urls, cb) # TODO: this branch can be removed in the future elif has_method(plugin, "getInfo"): self.log.debug( "Deprecated .getInfo() method on module level, use staticmethod instead" ) self.fetchForPlugin(plugin, urls, cb) if self.oc: self.oc.done = True self.names.clear() self.m.timestamp = time() + 5 * 60 self.progress = None self.finished()
def run(self): plugins = accumulate(self.data) crypter = {} # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: crypter[name] = plugins[name] del plugins[name] if crypter: # decrypt them links, packages = self.decrypt(crypter, err=True) # push these as initial result and save package names self.updateResult(links) for pack in packages: for url in pack.getURLs(): self.names[url] = pack.name links.extend(pack.links) self.updateResult(pack.links) # TODO: no plugin information pushed to GUI # parse links and merge hoster, crypter = self.m.core.pluginManager.parseUrls([l.url for l in links]) accumulate(hoster + crypter, plugins) # db or info result cb = self.updateDB if self.pid > 1 else self.updateResult self.progress = ProgressInfo("BasePlugin", "", _("online check"), 0, 0, sum(len(urls) for urls in plugins.itervalues()), self.owner, ProgressType.LinkCheck) for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.loadModule("hoster", pluginname) klass = self.m.core.pluginManager.getPluginClass("hoster", pluginname, overwrite=False) if has_method(klass, "getInfo"): self.fetchForPlugin(klass, urls, cb) # TODO: this branch can be removed in the future elif has_method(plugin, "getInfo"): self.log.debug("Deprecated .getInfo() method on module level, use staticmethod instead") self.fetchForPlugin(plugin, urls, cb) if self.oc: self.oc.done = True self.names.clear() self.m.timestamp = time() + 5 * 60 self.progress = None self.finished()
def _decrypt(self, urls): """Internal method to select decrypting method :param urls: List of urls/content :return: """ cls = self.__class__ # separate local and remote files content, urls = self.getLocalContent(urls) if has_method(cls, "decryptURLs"): self.setup() result = to_list(self.decryptURLs(urls)) elif has_method(cls, "decryptURL"): result = [] for url in urls: self.setup() result.extend(to_list(self.decryptURL(url))) elif has_method(cls, "decrypt"): self.logDebug("Deprecated .decrypt() method in Crypter plugin") result = [] for url in urls: self.pyfile = PyFileMockup(url) self.setup() self.decrypt(self.pyfile) result.extend(self.convertPackages()) else: if not has_method(cls, "decryptFile") or urls: self.logDebug("No suited decrypting method was overwritten in plugin") result = [] if has_method(cls, "decryptFile"): for f, c in content: self.setup() result.extend(to_list(self.decryptFile(c))) try: if f.startswith("tmp_"): remove(f) except IOError: self.logWarning(_("Could not remove file '%s'") % f) self.core.print_exc() return result
def _decrypt(self, urls): """ Internal method to select decrypting method :param urls: List of urls/content :return: """ cls = self.__class__ # separate local and remote files content, urls = self.getLocalContent(urls) if has_method(cls, "decryptURLs"): self.setup() result = to_list(self.decryptURLs(urls)) elif has_method(cls, "decryptURL"): result = [] for url in urls: self.setup() result.extend(to_list(self.decryptURL(url))) elif has_method(cls, "decrypt"): self.logDebug("Deprecated .decrypt() method in Crypter plugin") result = [] for url in urls: self.pyfile = PyFileMockup(url, self.package) self.setup() self.decrypt(self.pyfile) result.extend(self.convertPackages()) else: if not has_method(cls, "decryptFile") or urls: self.logDebug( "No suited decrypting method was overwritten in plugin") result = [] if has_method(cls, "decryptFile"): for f, c in content: self.setup() result.extend(to_list(self.decryptFile(c))) try: if f.startswith("tmp_"): remove(f) except: pass return result
def decrypt(self, plugin, urls): self.m.log.debug("Pre decrypting %s" % plugin) klass = self.m.core.pluginManager.loadClass("crypter", plugin) # only decrypt files if has_method(klass, "decryptFile"): urls = klass.decrypt(urls) data, crypter = self.m.core.pluginManager.parseUrls(urls) return data return []
def _decrypt(self, urls): """Internal method to select decrypting method :param urls: List of urls/content :return: """ cls = self.__class__ # separate local and remote files content, urls = self.getLocalContent(urls) result = [] if urls and has_method(cls, "decrypt"): self.logDebug("Deprecated .decrypt() method in Crypter plugin") result = [] for url in urls: self.pyfile = PyFileMockup(url) self.setup() self.decrypt(self.pyfile) result.extend(self.convertPackages()) elif urls: method = True try: self.setup() result = to_list(self.decryptURLs(urls)) except NotImplementedError: method = False # this will raise error if not implemented if not method: for url in urls: self.setup() result.extend(to_list(self.decryptURL(url))) for f, c in content: self.setup() result.extend(to_list(self.decryptFile(c))) try: if f.startswith("tmp_"): remove(f) except IOError: self.logWarning(_("Could not remove file '%s'") % f) self.core.print_exc() return result
def _decrypt(self, urls): """Internal method to select decrypting method :param urls: List of urls/content :return: (links, packages) """ cls = self.__class__ # separate local and remote files content, urls = self.getLocalContent(urls) result = [] if urls and has_method(cls, "decrypt"): self.logDebug("Deprecated .decrypt() method in Crypter plugin") result = [] for url in urls: self.pyfile = PyFileMockup(url, cls.__name__) self.setup() self.decrypt(self.pyfile) result.extend(self.convertPackages()) elif urls: method = True try: self.setup() result = to_list(self.decryptURLs(urls)) except NotImplementedError: method = False # this will raise error if not implemented if not method: for url in urls: self.setup() result.extend(to_list(self.decryptURL(url))) for f, c in content: self.setup() result.extend(to_list(self.decryptFile(c))) try: if f.startswith("tmp_"): remove(f) except IOError: self.logWarning(_("Could not remove file '%s'") % f) self.core.print_exc() return to_link_list(result)
def activate(self): """ called when addon was activated """ if has_method(self.__class__, "coreReady"): self.logWarning(_("Deprecated method `coreReady`, use `activate` instead")) self.coreReady()
def exit(self): """ called by core.shutdown just before pyLoad exit """ if has_method(self.__class__, "coreExiting"): self.coreExiting()
def activate(self): """ called when addon was activated """ if has_method(self.__class__, "coreReady"): self.logWarning( _("Deprecated method `coreReady`, use `activate` instead")) self.coreReady()
def deactivate(self): """ called when addon was deactivated """ if has_method(self.__class__, "unload"): self.logWarning( _("Deprecated method `unload`, use `deactivate` instead")) self.unload()
def run(self): """run method""" plugins = accumulate(self.data) crypter = {} # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: crypter[name] = plugins[name] del plugins[name] #directly write to database if self.pid > -1: for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.getPluginModule(pluginname) klass = self.m.core.pluginManager.getPluginClass(pluginname) if has_method(klass, "getInfo"): self.fetchForPlugin(pluginname, klass, urls, self.updateDB) self.m.core.files.save() elif has_method(plugin, "getInfo"): self.log.debug( "Deprecated .getInfo() method on module level, use classmethod instead" ) self.fetchForPlugin(pluginname, plugin, urls, self.updateDB) self.m.core.files.save() else: #post the results for name, urls in crypter.iteritems(): #attach container content try: data = self.decrypt(name, urls) except: print_exc() self.m.log.error("Could not decrypt container.") data = [] accumulate(data, plugins) self.m.infoResults[self.rid] = {} for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.getPluginModule(pluginname) klass = self.m.core.pluginManager.getPluginClass(pluginname) if has_method(klass, "getInfo"): self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) #force to process cache if self.cache: self.updateResult(pluginname, [], True) elif has_method(plugin, "getInfo"): self.log.debug( "Deprecated .getInfo() method on module level, use staticmethod instead" ) self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) #force to process cache if self.cache: self.updateResult(pluginname, [], True) else: #generate default result result = [(url, 0, 3, url) for url in urls] self.updateResult(pluginname, result, True) self.m.infoResults[self.rid]["ALL_INFO_FETCHED"] = {} self.m.timestamp = time() + 5 * 60
def activate(self): """ Used to activate the addon """ if has_method(self.__class__, "coreReady"): self.logDebug("Deprecated method .coreReady() use activate() instead") self.coreReady()
def activate(self): """ called when addon was activated """ if has_method(self.__class__, "coreReady"): self.coreReady()
def deactivate(self): """ called when addon was deactivated """ if has_method(self.__class__, "unload"): self.unload()
def deactivate(self): """ called when addon was deactivated """ if has_method(self.__class__, "unload"): self.logWarning(_("Deprecated method `unload`, use `deactivate` instead")) self.unload()
def activate(self): """ Used to activate the addon """ if has_method(self.__class__, "coreReady"): self.logDebug( "Deprecated method .coreReady() use activate() instead") self.coreReady()
def run(self): """run method""" plugins = accumulate(self.data) crypter = {} # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: crypter[name] = plugins[name] del plugins[name] #directly write to database if self.pid > -1: for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.getPluginModule(pluginname) klass = self.m.core.pluginManager.getPluginClass(pluginname) if has_method(klass, "getInfo"): self.fetchForPlugin(pluginname, klass, urls, self.updateDB) self.m.core.files.save() elif has_method(plugin, "getInfo"): self.log.debug("Deprecated .getInfo() method on module level, use classmethod instead") self.fetchForPlugin(pluginname, plugin, urls, self.updateDB) self.m.core.files.save() else: #post the results for name, urls in crypter: #attach container content try: data = self.decrypt(name, urls) except: print_exc() self.m.log.error("Could not decrypt container.") data = [] accumulate(data, plugins) self.m.infoResults[self.rid] = {} for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.getPlugin(pluginname, True) klass = getattr(plugin, pluginname) if has_method(klass, "getInfo"): self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) #force to process cache if self.cache: self.updateResult(pluginname, [], True) elif has_method(plugin, "getInfo"): self.log.debug("Deprecated .getInfo() method on module level, use staticmethod instead") self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) #force to process cache if self.cache: self.updateResult(pluginname, [], True) else: #generate default result result = [(url, 0, 3, url) for url in urls] self.updateResult(pluginname, result, True) self.m.infoResults[self.rid]["ALL_INFO_FETCHED"] = {} self.m.timestamp = time() + 5 * 60