.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
3
documentation"""
4
5
from
dateutil
import
parser
6
7
about = {
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
}
14
categories = [
'images'
,
'icons'
]
15
16
17
cdn_base_url =
'https://cdn.jsdelivr.net/gh/selfhst/icons'
18
19
20
def
request
(query, params):
21
params[
'url'
] = f
"{cdn_base_url}/index.json"
22
params[
'query'
] = query
23
return
params
24
25
26
def
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
searx.engines.selfhst.request
request(query, params)
Definition
selfhst.py:20
searx.engines.selfhst.response
response(resp)
Definition
selfhst.py:26
searxng
searx
engines
selfhst.py
Generated on
for .oO SearXNG Developer Documentation Oo. by
1.14.0