diff options
| author | Bnyro <bnyro@tutanota.com> | 2025-01-08 20:11:09 +0100 |
|---|---|---|
| committer | Bnyro <bnyro@tutanota.com> | 2025-03-17 20:23:54 +0100 |
| commit | 885d02c8c3a3ae54177eab81e672abe65a76acf5 (patch) | |
| tree | af73a67d23f5ae3198d10faec98748dfd72e217b /searx | |
| parent | bbb2894b049254a44faaa9393114129fb4030c4b (diff) | |
[feat] engine: add selfh.st/icons for logos of common self-hosted programs
Diffstat (limited to 'searx')
| -rw-r--r-- | searx/engines/selfhst.py | 54 | ||||
| -rw-r--r-- | searx/settings.yml | 6 |
2 files changed, 60 insertions, 0 deletions
diff --git a/searx/engines/selfhst.py b/searx/engines/selfhst.py new file mode 100644 index 000000000..a85c4e877 --- /dev/null +++ b/searx/engines/selfhst.py @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""selfh.st/icons - A collection of logos for self-hosted dashboards and +documentation""" + +from dateutil import parser + +about = { + 'website': 'https://selfh.st/icons/', + 'official_api_documentation': 'https://selfh.st/icons-about/', + "use_official_api": True, + "require_api_key": False, + "results": 'JSON', +} +categories = ['images'] + + +icons_list_url = 'https://cdn.selfh.st/directory/icons.json' +icons_cdn_base_url = 'https://cdn.jsdelivr.net' + + +def request(query, params): + params['url'] = icons_list_url + params['query'] = query + return params + + +def response(resp): + results = [] + + query_parts = resp.search_params['query'].lower().split(' ') + for item in resp.json(): + keyword = item['Reference'].lower() + if not any(query_part in keyword for query_part in query_parts): + continue + + img_format = None + for format_name in ('SVG', 'PNG', 'WebP'): + if item[format_name] == 'Yes': + img_format = format_name.lower() + break + + img_src = f'{icons_cdn_base_url}/gh/selfhst/icons/{img_format}/{item["Reference"]}.{img_format}' + result = { + 'template': 'images.html', + 'url': img_src, + 'title': item['Name'], + 'content': '', + 'img_src': img_src, + 'img_format': img_format, + 'publishedDate': parser.parse(item['CreatedAt']), + } + results.append(result) + + return results diff --git a/searx/settings.yml b/searx/settings.yml index 770f80ea7..3c9245bbd 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1757,6 +1757,12 @@ engines: about: website: https://searchmysite.net + - name: selfhst icons + engine: selfhst + shortcut: si + inactive: true + disabled: true + - name: sepiasearch engine: sepiasearch shortcut: sep |