.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
openverse.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""
3
4
Openverse (formerly known as: Creative Commons search engine) [Images]
5
6
"""
7
8
from
json
import
loads
9
from
urllib.parse
import
urlencode
10
11
12
about = {
13
"website"
:
'https://wordpress.org/openverse/'
,
14
"wikidata_id"
:
None
,
15
"official_api_documentation"
:
'https://api.openverse.engineering/v1/'
,
16
"use_official_api"
:
True
,
17
"require_api_key"
:
False
,
18
"results"
:
'JSON'
,
19
}
20
21
categories = [
'images'
]
22
23
paging =
True
24
nb_per_page = 20
25
26
base_url =
'https://api.openverse.engineering/v1/images/'
27
search_string =
'?page={page}&page_size={nb_per_page}&format=json&{query}'
28
29
30
def
request
(query, params):
31
32
search_path = search_string.format(query=urlencode({
'q'
: query}), nb_per_page=nb_per_page, page=params[
'pageno'
])
33
34
params[
'url'
] = base_url + search_path
35
36
return
params
37
38
39
def
response
(resp):
40
results = []
41
42
json_data = loads(resp.text)
43
44
for
result
in
json_data[
'results'
]:
45
results.append(
46
{
47
'url'
: result[
'foreign_landing_url'
],
48
'title'
: result[
'title'
],
49
'img_src'
: result[
'url'
],
50
'template'
:
'images.html'
,
51
}
52
)
53
54
return
results
searx.engines.openverse.response
response(resp)
Definition
openverse.py:39
searx.engines.openverse.request
request(query, params)
Definition
openverse.py:30
searxng
searx
engines
openverse.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0