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 run(self): pack = self.core.files.getPackage(self.pid) api = self.core.api.withUserContext(self.owner) links, packages = self.decrypt(accumulate(self.data), pack.password) # if there is only one package links will be added to current one if len(packages) == 1: # TODO: also rename the package (optionally) links.extend(packages[0].links) del packages[0] if links: self.log.info( _("Decrypted %(count)d links into package %(name)s") % { "count": len(links), "name": pack.name }) api.addLinks(self.pid, [l.url for l in links]) for p in packages: api.addPackage(p.name, p.getURLs(), pack.password) self.core.files.setDownloadStatus( self.fid, DS.Finished if not self.error else DS.Failed) self.m.done(self)
def run(self): pack = self.m.core.files.getPackage(self.pid) links, packages = self.decrypt(accumulate(self.data), pack.password) if links: self.log.info(_("Decrypted %(count)d links into package %(name)s") % {"count": len(links), "name": pack.name}) self.m.core.api.addFiles(self.pid, [l.url for l in links]) # TODO: add single package into this one and rename it? # TODO: nested packages for p in packages: self.m.core.api.addPackage(p.name, p.getURLs(), pack.password)
def updateResult(self, result): tmp = {} parse = [] # separate these with name and without for link in result: if link.url in self.names: tmp[link] = self.names[link.url] else: parse.append(link) data = parseNames([(link.name, link) for link in parse]) # merge in packages that already have a name data = accumulate(tmp.iteritems(), data) self.m.setInfoResults(self.oc, data)
def run(self): pack = self.m.core.files.getPackage(self.pid) links, packages = self.decrypt(accumulate(self.data), pack.password) if links: self.log.info( _("Decrypted %(count)d links into package %(name)s") % { "count": len(links), "name": pack.name }) self.m.core.api.addFiles(self.pid, [l.url for l in links]) # TODO: add single package into this one and rename it? # TODO: nested packages for p in packages: self.m.core.api.addPackage(p.name, p.getURLs(), pack.password)
def run(self): pack = self.core.files.getPackage(self.pid) api = self.core.api.withUserContext(self.owner) links, packages = self.decrypt(accumulate(self.data), pack.password) # if there is only one package links will be added to current one if len(packages) == 1: # TODO: also rename the package (optionally) links.extend(packages[0].links) del packages[0] if links: self.log.info( _("Decrypted %(count)d links into package %(name)s") % {"count": len(links), "name": pack.name}) api.addLinks(self.pid, [l.url for l in links]) for p in packages: api.addPackage(p.name, p.getURLs(), pack.password) self.core.files.setDownloadStatus(self.fid, DS.Finished if not self.error else DS.Failed) self.m.done(self)
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
for l in links: if not l or l.startswith("#"): continue if l.startswith("http"): if "||" in l: l, flag = l.split("||") flags[l] = str(flag.strip()) urls.append(l) elif len(l.rsplit(" ", 1)) == 2: name, hash = l.rsplit(" ", 1) HosterPluginTester.files[name] = str(hash) hoster, c = c.pluginManager.parseUrls(urls) plugins = accumulate(hoster) for plugin, urls in plugins.iteritems(): # closure functions to retain local scope def meta_class(plugin): class _testerClass(HosterPluginTester): pass _testerClass.__name__ = plugin return _testerClass _testerClass = meta_class(plugin) for i, url in enumerate(urls): def meta(__plugin, url, flag, sig): def _test(self):
f = open(join(dirname(__file__), "crypterlinks.txt")) links = [x.strip() for x in f.readlines()] urls = [] flags = {} for l in links: if not l or l.startswith("#"): continue if l.startswith("http"): if "||" in l: l, flag = l.split("||") flags[l] = flag urls.append(l) h, crypter = c.pluginManager.parseUrls(urls) plugins = accumulate(crypter) for plugin, urls in plugins.iteritems(): def meta_class(plugin): class _testerClass(CrypterPluginTester): pass _testerClass.__name__ = plugin return _testerClass _testerClass = meta_class(plugin) for i, url in enumerate(urls): def meta(plugin, url, flag, sig): def _test(self): self.test_plugin(plugin, url, flag)
del sections["files"] urls = [] status = {} for k, v in sections.iteritems(): if k not in statusMap: print "Unknown status %s" % k for url in v: urls.append(url) status[url] = k hoster, c = c.pluginManager.parseUrls(urls) plugins = accumulate(hoster) for plugin, urls in plugins.iteritems(): # closure functions to retain local scope def meta_class(plugin): class _testerClass(HosterPluginTester): pass _testerClass.__name__ = plugin return _testerClass _testerClass = meta_class(plugin) for i, url in enumerate(urls): def meta(__plugin, url, status, sig): def _test(self): self.test_plugin(__plugin, url, status)
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