diff options
author | Bnyro <bnyro@tutanota.com> | 2024-02-19 20:22:54 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-02-25 14:56:57 +0100 |
commit | 1d6f475fbce9ec694ecebee18384c68be440a2c2 (patch) | |
tree | 2d08a67987598f32f92eba313616f8ca6b3a6f84 /searx | |
parent | 60d8414ef158e648176f0d0f6cfef6ab709c4a53 (diff) | |
download | searxng-1d6f475fbce9ec694ecebee18384c68be440a2c2.tar.gz searxng-1d6f475fbce9ec694ecebee18384c68be440a2c2.zip |
[feat] dockerhub: use packages template
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/docker_hub.py | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/searx/engines/docker_hub.py b/searx/engines/docker_hub.py index cde96d016..1e2527823 100644 --- a/searx/engines/docker_hub.py +++ b/searx/engines/docker_hub.py @@ -5,7 +5,6 @@ """ # pylint: disable=use-dict-literal -from json import loads from urllib.parse import urlencode from dateutil import parser @@ -18,7 +17,7 @@ about = { "results": 'JSON', } -categories = ['it'] # optional +categories = ['it', 'packages'] # optional paging = True base_url = "https://hub.docker.com/" @@ -38,26 +37,24 @@ def response(resp): resp: requests response object ''' results = [] - body = loads(resp.text) - - # Make sure `summaries` isn't `null` - search_res = body.get("summaries") - if search_res: - for item in search_res: - result = {} - - # Make sure correct URL is set - filter_type = item.get("filter_type") - is_official = filter_type in ["store", "official"] - - if is_official: - result["url"] = base_url + "_/" + item.get('slug', "") - else: - result["url"] = base_url + "r/" + item.get('slug', "") - result["title"] = item.get("name") - result["content"] = item.get("short_description") - result["publishedDate"] = parser.parse(item.get("updated_at") or item.get("created_at")) - result["thumbnail"] = item["logo_url"].get("large") or item["logo_url"].get("small") - results.append(result) + body = resp.json() + + for item in body.get("summaries", []): + filter_type = item.get("filter_type") + is_official = filter_type in ["store", "official"] + + result = { + 'template': 'packages.html', + 'url': base_url + ("_/" if is_official else "r/") + item.get("slug", ""), + 'title': item.get("name"), + 'content': item.get("short_description"), + 'img_src': item["logo_url"].get("large") or item["logo_url"].get("small"), + 'package_name': item.get("name"), + 'maintainer': item["publisher"].get("name"), + 'publishedDate': parser.parse(item.get("updated_at") or item.get("created_at")), + 'popularity': item.get("pull_count", "0") + " pulls", + 'tags': [arch['name'] for arch in item["architectures"]], + } + results.append(result) return results |