diff options
author | Noémi Ványi <sitbackandwait@gmail.com> | 2020-02-01 11:01:17 +0100 |
---|---|---|
committer | Noémi Ványi <sitbackandwait@gmail.com> | 2020-02-08 11:47:39 +0100 |
commit | 99435381a84072b110c32004b2fb778af9b96f77 (patch) | |
tree | 9ad5fd222e6717312ef05dbcd871ef46a97857e5 /searx/engines/__init__.py | |
parent | f9c7a678d273c55a0e8a1a7a2dbfd696b2046e60 (diff) | |
download | searxng-99435381a84072b110c32004b2fb778af9b96f77.tar.gz searxng-99435381a84072b110c32004b2fb778af9b96f77.zip |
[enh] introduce private engines
This PR adds a new setting to engines named `tokens`.
It expects a list of tokens which lets searx validate
if the request should be accepted or not.
Diffstat (limited to 'searx/engines/__init__.py')
-rw-r--r-- | searx/engines/__init__.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 2393f52b6..9ccef8b54 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -54,7 +54,8 @@ engine_default_args = {'paging': False, 'suspend_end_time': 0, 'continuous_errors': 0, 'time_range_support': False, - 'offline': False} + 'offline': False, + 'tokens': []} def load_engine(engine_data): @@ -160,7 +161,7 @@ def to_percentage(stats, maxvalue): return stats -def get_engines_stats(): +def get_engines_stats(preferences): # TODO refactor pageloads = [] engine_times = [] @@ -171,8 +172,12 @@ def get_engines_stats(): max_pageload = max_engine_times = max_results = max_score = max_errors = max_score_per_result = 0 # noqa for engine in engines.values(): + if not preferences.validate_token(engine): + continue + if engine.stats['search_count'] == 0: continue + results_num = \ engine.stats['result_count'] / float(engine.stats['search_count']) |