.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
selfhst.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""selfh.st/icons - A collection of logos for self-hosted dashboards and
3documentation"""
4
5from dateutil import parser
6
7about = {
8 'website': 'https://selfh.st/icons/',
9 'official_api_documentation': 'https://selfh.st/icons-about/',
10 "use_official_api": True,
11 "require_api_key": False,
12 "results": 'JSON',
13}
14categories = ['images', 'icons']
15
16
17cdn_base_url = 'https://cdn.jsdelivr.net/gh/selfhst/icons'
18
19
20def request(query, params):
21 params['url'] = f"{cdn_base_url}/index.json"
22 params['query'] = query
23 return params
24
25
26def response(resp):
27 results = []
28
29 query_parts = resp.search_params['query'].lower().split(' ')
30 for item in resp.json():
31 keyword = item['Reference'].lower()
32 if not any(query_part in keyword for query_part in query_parts):
33 continue
34
35 img_format = None
36 for format_name in ('SVG', 'PNG', 'WebP'):
37 if item[format_name] == 'Yes':
38 img_format = format_name.lower()
39 break
40
41 img_src = f'{cdn_base_url}/{img_format}/{item["Reference"]}.{img_format}'
42 result = {
43 'template': 'images.html',
44 'url': img_src,
45 'title': item['Name'],
46 'content': '',
47 'img_src': img_src,
48 'img_format': img_format,
49 'publishedDate': parser.parse(item['CreatedAt']),
50 }
51 results.append(result)
52
53 return results
request(query, params)
Definition selfhst.py:20