mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-03 22:22:33 -06:00
[search engine] Final enhancements.
This commit is contained in:
@@ -116,6 +116,8 @@ def displayCapabilities(supported_engines):
|
||||
def run_search(engine_list):
|
||||
""" Run search in engine
|
||||
|
||||
@param engine_list List with engine, query and category
|
||||
|
||||
@retval False if any exceptions occured
|
||||
@retval True otherwise
|
||||
"""
|
||||
@@ -128,6 +130,7 @@ def run_search(engine_list):
|
||||
engine.search(what, cat)
|
||||
else:
|
||||
engine.search(what)
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
@@ -147,6 +150,7 @@ def main(args):
|
||||
raise SystemExit("./nova2.py [all|engine1[,engine2]*] <category> <keywords>\n"
|
||||
"available engines: %s" % (','.join(supported_engines)))
|
||||
|
||||
#get only unique engines with set
|
||||
engines_list = set(e.lower() for e in args[0].strip().split(','))
|
||||
|
||||
if 'all' in engines_list:
|
||||
@@ -166,12 +170,13 @@ def main(args):
|
||||
raise SystemExit(" - ".join(('Invalid category', cat)))
|
||||
|
||||
what = urllib.parse.quote(' '.join(args[2:]))
|
||||
|
||||
if THREADED:
|
||||
#child process spawning is controlled min(number of searches, number of cpu)
|
||||
with Pool(min(len(engines_list), cpu_count())) as pool:
|
||||
pool.map(run_search, ([globals()[engine], what, cat] for engine in engines_list))
|
||||
else:
|
||||
_ = [run_search([globals()[engine], what, cat]) for engine in engines_list]
|
||||
#py3 note: map is needed to be evaluated for content to be executed
|
||||
all(map(run_search, ([globals()[engine], what, cat] for engine in engines_list)))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(argv[1:])
|
||||
|
||||
Reference in New Issue
Block a user