.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.docker_hub Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['it', 'packages']
 
bool paging = True
 
str base_url = "https://hub.docker.com"
 
int page_size = 10
 

Detailed Description

Docker Hub (IT)

Function Documentation

◆ request()

searx.engines.docker_hub.request ( query,
params )

Definition at line 26 of file docker_hub.py.

26def request(query, params):
27 args = {
28 "query": query,
29 "from": page_size * (params['pageno'] - 1),
30 "size": page_size,
31 }
32 params['url'] = f"{base_url}/api/search/v3/catalog/search?{urlencode(args)}"
33
34 return params
35
36

◆ response()

searx.engines.docker_hub.response ( resp)
post-response callback
resp: requests response object

Definition at line 37 of file docker_hub.py.

37def response(resp):
38 '''post-response callback
39 resp: requests response object
40 '''
41 results = []
42 json_resp = resp.json()
43
44 for item in json_resp.get("results", []):
45 image_source = item.get("source")
46 is_official = image_source in ["store", "official"]
47
48 popularity_infos = [f"{item.get('star_count', 0)} stars"]
49
50 architectures = []
51 for rate_plan in item.get("rate_plans", []):
52 pull_count = rate_plan.get("repositories", [{}])[0].get("pull_count")
53 if pull_count:
54 popularity_infos.insert(0, f"{pull_count} pulls")
55 architectures.extend(arch['name'] for arch in rate_plan.get("architectures", []) if arch['name'])
56
57 result = {
58 'template': 'packages.html',
59 'url': base_url + ("/_/" if is_official else "/r/") + item.get("slug", ""),
60 'title': item.get("name"),
61 'content': item.get("short_description"),
62 'thumbnail': item["logo_url"].get("large") or item["logo_url"].get("small"),
63 'package_name': item.get("name"),
64 'maintainer': item["publisher"].get("name"),
65 'publishedDate': parser.parse(item.get("updated_at") or item.get("created_at")),
66 'popularity': ', '.join(popularity_infos),
67 'tags': architectures,
68 }
69 results.append(result)
70
71 return results

Variable Documentation

◆ about

dict searx.engines.docker_hub.about
Initial value:
1= {
2 "website": 'https://hub.docker.com',
3 "wikidata_id": 'Q100769064',
4 "official_api_documentation": 'https://docs.docker.com/registry/spec/api/',
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 10 of file docker_hub.py.

◆ base_url

str searx.engines.docker_hub.base_url = "https://hub.docker.com"

Definition at line 22 of file docker_hub.py.

◆ categories

list searx.engines.docker_hub.categories = ['it', 'packages']

Definition at line 19 of file docker_hub.py.

◆ page_size

int searx.engines.docker_hub.page_size = 10

Definition at line 23 of file docker_hub.py.

◆ paging

bool searx.engines.docker_hub.paging = True

Definition at line 20 of file docker_hub.py.