mirror of
https://github.com/searxng/searxng.git
synced 2024-05-19 20:08:04 +00:00
[feat] gitea: implement dedicated module
This commit is contained in:
parent
58320222e2
commit
cd05fdeb94
57
searx/engines/gitea.py
Normal file
57
searx/engines/gitea.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""Github (IT)
|
||||
|
||||
"""
|
||||
|
||||
from urllib.parse import urlencode
|
||||
from dateutil import parser
|
||||
|
||||
about = {
|
||||
"website": 'https://about.gitea.com',
|
||||
"wikidata_id": None,
|
||||
"official_api_documentation": 'https://docs.gitea.com/next/development/api-usage',
|
||||
"use_official_api": True,
|
||||
"require_api_key": False,
|
||||
"results": 'JSON',
|
||||
}
|
||||
|
||||
categories = ['it', 'repos']
|
||||
paging = True
|
||||
|
||||
base_url = "https://codeberg.org"
|
||||
page_size = 10
|
||||
sort = "updated" # possible values: "alpha", "created", "updated", "size", "id"
|
||||
order = "desc" # or "asc"
|
||||
|
||||
|
||||
def request(query, params):
|
||||
args = {'q': query, 'limit': page_size, 'sort': sort, 'order': order, 'page': params['pageno']}
|
||||
params['url'] = f"{base_url}/api/v1/repos/search?{urlencode(args)}"
|
||||
|
||||
return params
|
||||
|
||||
|
||||
def response(resp):
|
||||
results = []
|
||||
|
||||
for item in resp.json().get('data', []):
|
||||
content = [item.get(i) for i in ['language', 'description'] if item.get(i)]
|
||||
|
||||
results.append(
|
||||
{
|
||||
'template': 'packages.html',
|
||||
'url': item.get('html_url'),
|
||||
'title': item.get('full_name'),
|
||||
'content': ' / '.join(content),
|
||||
'img_src': item.get('owner', {}).get('avatar_url'),
|
||||
'package_name': item.get('name'),
|
||||
'maintainer': item.get('owner', {}).get('login'),
|
||||
'publishedDate': parser.parse(item.get("updated_at") or item.get("created_at")),
|
||||
'tags': item.get('topics', []),
|
||||
'popularity': item.get('stargazers_count'),
|
||||
'homepage': item.get('homepage'),
|
||||
'source_code_url': item.get('clone_url'),
|
||||
}
|
||||
)
|
||||
|
||||
return results
|
|
@ -805,21 +805,13 @@ engines:
|
|||
# new engine by copying this and changing the name, shortcut and search_url.
|
||||
|
||||
- name: codeberg
|
||||
engine: json_engine
|
||||
search_url: https://codeberg.org/api/v1/repos/search?q={query}&limit=10
|
||||
url_query: html_url
|
||||
title_query: name
|
||||
content_query: description
|
||||
categories: [it, repos]
|
||||
engine: gitea
|
||||
# base_url: https://codeberg.org
|
||||
# page_size: 10
|
||||
# sort: created
|
||||
# order: desc
|
||||
shortcut: cb
|
||||
disabled: true
|
||||
about:
|
||||
website: https://codeberg.org/
|
||||
wikidata_id:
|
||||
official_api_documentation: https://try.gitea.io/api/swagger
|
||||
use_official_api: false
|
||||
require_api_key: false
|
||||
results: JSON
|
||||
|
||||
- name: goodreads
|
||||
engine: goodreads
|
||||
|
|
Loading…
Reference in a new issue