def run(self): plugins = accumulate(self.data) crypter = {} # db or info result cb = self.update_db if self.pid > 1 else self.update_result # filter out crypter plugins for name in self.manager.pyload.pgm.get_plugins("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.get_urls(): 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.manager.pyload.pgm.parse_urls( 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.values()), self.owner, ProgressType.LinkCheck) for pluginname, urls in plugins.items(): plugin = self.manager.pyload.pgm.load_module("hoster", pluginname) klass = self.manager.pyload.pgm.get_plugin_class("hoster", pluginname, overwrite=False) if hasmethod(klass, "get_info"): self.fetch_for_plugin(klass, urls, cb) # TODO: this branch can be removed in the future elif hasmethod(plugin, "get_info"): self.pyload.log.debug( "Deprecated .get_info() method on module level, use staticmethod instead" ) self.fetch_for_plugin(plugin, urls, cb) if self.oc: self.oc.done = True self.names.clear() self.manager.timestamp = time() + 5 * 60 self.progress = None self.finished()
def run(self): plugins = accumulate(self.data) crypter = {} # db or info result cb = self.update_db if self.pid > 1 else self.update_result # filter out crypter plugins for name in self.pyload.pgm.get_plugins('crypter'): if name in plugins: crypter[name] = plugins[name] del plugins[name] if crypter: # decrypt them links, packages = self.decrypt(crypter) # push these as initial result and save package names cb(links) for pack in packages: for url in pack.get_urls(): 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.pyload.pgm.parse_urls( l.url for l in links) accumulate(hoster + crypter, plugins) self.__progress_info = ProgressInfo( 'BasePlugin', '', self._('online check'), 0, 0, sum(len(urls) for urls in plugins.values()), self.owner, ProgressType.LinkCheck ) for pluginname, urls in plugins.items(): plugin = self.pyload.pgm.load_module('hoster', pluginname) klass = self.pyload.pgm.get_plugin_class( 'hoster', pluginname, overwrite=False) if hasmethod(klass, 'get_info'): self.fetch_for_plugin(klass, urls, cb) # TODO: this branch can be removed in the future elif hasmethod(plugin, 'get_info'): self.pyload.log.debug( 'Deprecated .get_info() method on module level, ' 'use staticmethod instead') self.fetch_for_plugin(plugin, urls, cb) if self.oc: self.oc.done = True self.names.clear() self.manager.timestamp = time.time() + 5 * 60 self.__progress_info = None self.finished()
def activate(self): """ Used to activate the addon. """ if hasmethod(self.__class__, "core_ready"): self.log_debug( "Deprecated method .core_ready() use activate() instead") self.pyload_ready()
def activate(self): """ Used to activate the addon. """ if hasmethod(self.__class__, "core_ready"): self.log_debug( "Deprecated method .core_ready() use activate() instead") self.pyload_ready()
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.get_local_content(urls) result = [] if urls and hasmethod(cls, "decrypt"): self.log_debug("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.convert_packages()) elif urls: method = True try: self.setup() result = to_list(self.decrypt_urls(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.decrypt_url(url), [])) for f, c in content: self.setup() result.extend(to_list(self.decrypt_file(c), [])) try: if f.startswith("tmp_"): remove(f) except IOError: self.log_warning(_("Could not delete file '{0}'").format(f)) # self.pyload.print_exc() return to_link_list(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.get_local_content(urls) result = [] if urls and hasmethod(cls, "decrypt"): self.log_debug("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.convert_packages()) elif urls: method = True try: self.setup() result = to_list(self.decrypt_urls(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.decrypt_url(url), [])) for f, c in content: self.setup() result.extend(to_list(self.decrypt_file(c), [])) try: if f.startswith("tmp_"): remove(f) except IOError: self.log_warning(_("Could not delete file '{0}'").format(f)) # self.pyload.print_exc() return to_link_list(result)