def run(self, api_mode=False): items = dict() if self.targets[0] == "all": self.targets.pop() self.targets = list_wg_modules() for target in self.targets: if not self.results_type and not api_mode: msg_fetching(target) path = "we_get.modules.%s" % (target) try: run = import_module(path) except ImportError: msg_error("Cannot find target \'%s\'." % (target), True) except Exception: msg_info("Module: \'%s.py\' stopped!" % (target)) msg_err_trace(True) try: items = run.main(self.pargs) except HTTPError: continue items = self.add_items_label(target, items) if items: self.items.update(items) else: msg_error(" \'%s\' - no results" % (target), False) continue """Sort self.items""" if self.filter: self.items = self.filter_items(self.filter) if self.sort_type == "name": self.items = self.sort_items_by_name(self.items) else: self.items = self.sort_items_by_seeds(self.items) # items cut must at the end of item processing. if self.results: self.items = self.cut_items(self.items, self.results) if api_mode: return self.items elif self.results_type == 'J': print(dumps(self.items, indent=2, sort_keys=True)) elif self.results_type == 'L': [print(self.items[item]['link']) for item in self.items] else: # XXX: import we_get.core.shell is here for optimization. # we-get will load 50% faster! from we_get.core.shell import Shell self.shell = Shell() if hasattr(self, 'config') and self.config['item_color']: self.shell.item_color.update(self.config['item_color']) self.shell.shell(self.items, self.pargs)
def run(self): items = dict() if self.targets[0] == "all": msg_warning("using 'all' is not recommended!") self.targets.pop() self.targets = list_wg_modules() for target in self.targets: if not self.results_type: msg_fetching(target) path = "we_get.modules.%s" % (target) try: run = import_module(path) except ImportError: msg_error("Cannot find target \'%s\'." % (target), True) except Exception: msg_info("Module: \'%s.py\' stopped!" % (target)) msg_err_trace(True) items = run.main(self.pargs) items = self.add_items_label(target, items) if items: self.items.update(items) else: msg_error(" \'%s\' - no results" % (target), False) if not self.items: return if self.filter: self.items = self.filter_items(self.filter) if self.results: self.items = self.cut_items(self.items, self.results) if self.sort_type == "name": self.items = self.sort_items_by_name(self.items) else: self.items = self.sort_items_by_seeds(self.items) if self.results_type == 'J': print(dumps(self.items, indent=2, sort_keys=True)) elif self.results_type == 'L': [print(self.items[item]['link']) for item in self.items] else: # XXX: import we_get.core.shell is here for optimization. # we-get will load 50% faster! from we_get.core.shell import Shell self.shell = Shell() self.shell.shell(self.items, self.pargs)