summaryrefslogtreecommitdiff
path: root/searx/utils.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2015-02-03 18:37:38 +0100
committerAdam Tauber <asciimoo@gmail.com>2015-02-03 18:37:38 +0100
commit1de781a143270c8f1f98a04b688b8546ad341ec5 (patch)
treef9e48a7644e88a2909d0f5e4a2ac251baa4ff9a1 /searx/utils.py
parent268e0516eee10f97891aa8a136fd910460f71660 (diff)
downloadsearxng-1de781a143270c8f1f98a04b688b8546ad341ec5.tar.gz
searxng-1de781a143270c8f1f98a04b688b8546ad341ec5.zip
[enh] category specific engine deactivation - closes #205
Diffstat (limited to 'searx/utils.py')
-rw-r--r--searx/utils.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/searx/utils.py b/searx/utils.py
index c0afc94cb..a42458829 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -231,7 +231,21 @@ def prettify_url(url):
def get_blocked_engines(engines, cookies):
if 'blocked_engines' not in cookies:
- return [engine for engine in engines if engines[engine].disabled]
+ return [(engine, category) for engine in engines for category in engines.category if engines[engine].disabled]
- return [engine for engine in cookies.get('blocked_engines', '').split(',')
- if engine in engines]
+ blocked_engine_strings = cookies.get('blocked_engines', '').split(',')
+ blocked_engines = []
+
+ if not blocked_engine_strings:
+ return blocked_engines
+
+ for engine_string in blocked_engine_strings:
+ if engine_string.find('__') > -1:
+ engine, category = engine_string.split('__', 1)
+ if engine in engines and category in engines[engine].categories:
+ blocked_engines.append((engine, category))
+ elif engine_string in engines:
+ for category in engines[engine_string].categories:
+ blocked_engines.append((engine_string, category))
+
+ return blocked_engines