From 870fd2823c157b645a319ee2af6544ab57a81902 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 15 Oct 2024 11:06:07 +0200 Subject: [PATCH] [feat] duckduckgo images: add license filter support --- searx/engines/duckduckgo_extra.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/searx/engines/duckduckgo_extra.py b/searx/engines/duckduckgo_extra.py index b30574d6c..8a4bc1672 100644 --- a/searx/engines/duckduckgo_extra.py +++ b/searx/engines/duckduckgo_extra.py @@ -45,6 +45,7 @@ safesearch_cookies = {0: '-2', 1: None, 2: '1'} safesearch_args = {0: '1', 1: None, 2: '1'} search_path_map = {'images': 'i', 'videos': 'v', 'news': 'news'} +license_map = {'public': 'Public', 'freetouse': 'Modify', 'commercial': ''} def request(query, params): @@ -59,12 +60,16 @@ def request(query, params): eng_region = traits.get_region(params['searxng_locale'], traits.all_locale) eng_lang = get_ddg_lang(traits, params['searxng_locale']) + f_arg = '' + if ddg_category == 'images' and params['license_filter']: + f_arg = 'license:' + license_map[params['license_filter']] + args = { 'q': query, 'o': 'json', # 'u': 'bing', 'l': eng_region, - 'f': ',,,,,', + 'f': ',,,,,' + f_arg, 'vqd': vqd, }