4 Commits

Author SHA1 Message Date
Markus Heiser
655e41f274 [l10n ga] trigger weblate.push.translations
Related:

- https://github.com/searxng/searxng/issues/4117

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-01-06 14:54:41 +01:00
Aindriú Mac Giolla Eoin
d9343b6388 [l10n] adding new language Irish (ga) 2025-01-06 14:54:41 +01:00
Bnyro
0642c5434a [fix] dockerhub: switch to new api path
Co-authored-by: Markus Heiser <markus.heiser@darmarit.de>
2025-01-06 13:46:13 +01:00
Lucki
18c3e08837 Fix usage of api_key engine setting
The value of `params['api_key']` isn't read anywhere.
Writing directly into the header object solves this quite easily though.

> [Users can authenticate by including their API key either in a request URL by appending `?apikey=<API KEY>`, or by including the `X-API-Key: <API KEY>` header with the request.](https://wallhaven.cc/help/api)
2025-01-06 12:25:33 +01:00
6 changed files with 1554 additions and 14 deletions

View File

@@ -21,6 +21,7 @@
"fi": "Suomi (Finnish)",
"fil": "Filipino",
"fr": "Français (French)",
"ga": "Gaeilge (Irish)",
"gl": "Galego (Galician)",
"he": "עברית (Hebrew)",
"hr": "Hrvatski (Croatian)",
@@ -67,4 +68,4 @@
"fa-IR",
"he"
]
}
}

View File

@@ -19,14 +19,17 @@ about = {
categories = ['it', 'packages'] # optional
paging = True
base_url = "https://hub.docker.com/"
search_url = base_url + "api/content/v1/products/search?{query}&type=image&page_size=25"
base_url = "https://hub.docker.com"
page_size = 10
def request(query, params):
params['url'] = search_url.format(query=urlencode(dict(q=query, page=params["pageno"])))
params["headers"]["Search-Version"] = "v3"
args = {
"query": query,
"from": page_size * (params['pageno'] - 1),
"size": page_size,
}
params['url'] = f"{base_url}/api/search/v3/catalog/search?{urlencode(args)}"
return params
@@ -36,23 +39,32 @@ def response(resp):
resp: requests response object
'''
results = []
body = resp.json()
json_resp = resp.json()
for item in body.get("summaries", []):
filter_type = item.get("filter_type")
is_official = filter_type in ["store", "official"]
for item in json_resp.get("results", []):
image_source = item.get("source")
is_official = image_source in ["store", "official"]
popularity_infos = [f"{item.get('star_count', 0)} stars"]
architectures = []
for rate_plan in item.get("rate_plans", []):
pull_count = rate_plan.get("repositories", [{}])[0].get("pull_count")
if pull_count:
popularity_infos.insert(0, f"{pull_count} pulls")
architectures.extend(arch['name'] for arch in rate_plan.get("architectures", []) if arch['name'])
result = {
'template': 'packages.html',
'url': base_url + ("_/" if is_official else "r/") + item.get("slug", ""),
'url': base_url + ("/_/" if is_official else "/r/") + item.get("slug", ""),
'title': item.get("name"),
'content': item.get("short_description"),
'thumbnail': 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"]],
'popularity': ', '.join(popularity_infos),
'tags': architectures,
}
results.append(result)

View File

@@ -57,7 +57,7 @@ def request(query, params):
}
if api_key:
params['api_key'] = api_key
params['headers']['X-API-Key'] = api_key
params['url'] = f"{base_url}/api/v1/search?{urlencode(args)}"
return params

View File

@@ -36,6 +36,7 @@ CATEGORY_NAMES = {
'MAP': 'map',
'ONIONS': 'onions',
'SCIENCE': 'science',
'DUMMY': 'dummy',
}
CATEGORY_GROUPS = {

Binary file not shown.

File diff suppressed because it is too large Load Diff