.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
docker_hub.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""Docker Hub (IT)
3
4"""
5# pylint: disable=use-dict-literal
6
7from urllib.parse import urlencode
8from dateutil import parser
9
10about = {
11 "website": 'https://hub.docker.com',
12 "wikidata_id": 'Q100769064',
13 "official_api_documentation": 'https://docs.docker.com/registry/spec/api/',
14 "use_official_api": True,
15 "require_api_key": False,
16 "results": 'JSON',
17}
18
19categories = ['it', 'packages'] # optional
20paging = True
21
22base_url = "https://hub.docker.com/"
23search_url = base_url + "api/content/v1/products/search?{query}&type=image&page_size=25"
24
25
26def request(query, params):
27
28 params['url'] = search_url.format(query=urlencode(dict(q=query, page=params["pageno"])))
29 params["headers"]["Search-Version"] = "v3"
30
31 return params
32
33
34def response(resp):
35 '''post-response callback
36 resp: requests response object
37 '''
38 results = []
39 body = resp.json()
40
41 for item in body.get("summaries", []):
42 filter_type = item.get("filter_type")
43 is_official = filter_type in ["store", "official"]
44
45 result = {
46 'template': 'packages.html',
47 'url': base_url + ("_/" if is_official else "r/") + item.get("slug", ""),
48 'title': item.get("name"),
49 'content': item.get("short_description"),
50 'img_src': item["logo_url"].get("large") or item["logo_url"].get("small"),
51 'package_name': item.get("name"),
52 'maintainer': item["publisher"].get("name"),
53 'publishedDate': parser.parse(item.get("updated_at") or item.get("created_at")),
54 'popularity': item.get("pull_count", "0") + " pulls",
55 'tags': [arch['name'] for arch in item["architectures"]],
56 }
57 results.append(result)
58
59 return results
request(query, params)
Definition docker_hub.py:26