2021-01-13 10:31:25 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2016-03-26 21:50:44 +00:00
|
|
|
"""
|
|
|
|
F-Droid (a repository of FOSS applications for Android)
|
|
|
|
"""
|
|
|
|
|
2020-08-06 15:42:46 +00:00
|
|
|
from urllib.parse import urlencode
|
2016-03-26 21:50:44 +00:00
|
|
|
from lxml import html
|
2020-10-02 16:13:56 +00:00
|
|
|
from searx.utils import extract_text
|
2016-03-26 21:50:44 +00:00
|
|
|
|
2021-01-13 10:31:25 +00:00
|
|
|
# about
|
|
|
|
about = {
|
|
|
|
"website": 'https://f-droid.org/',
|
|
|
|
"wikidata_id": 'Q1386210',
|
|
|
|
"official_api_documentation": None,
|
|
|
|
"use_official_api": False,
|
|
|
|
"require_api_key": False,
|
|
|
|
"results": 'HTML',
|
|
|
|
}
|
|
|
|
|
2016-03-26 21:50:44 +00:00
|
|
|
# engine dependent config
|
2021-12-22 15:58:52 +00:00
|
|
|
categories = ['files', 'apps']
|
2016-03-26 21:50:44 +00:00
|
|
|
paging = True
|
|
|
|
|
|
|
|
# search-url
|
2019-08-05 13:44:02 +00:00
|
|
|
base_url = 'https://search.f-droid.org/'
|
|
|
|
search_url = base_url + '?{query}'
|
2016-03-26 21:50:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
# do search-request
|
|
|
|
def request(query, params):
|
2019-08-05 13:44:02 +00:00
|
|
|
query = urlencode({'q': query, 'page': params['pageno'], 'lang': ''})
|
2016-03-26 21:50:44 +00:00
|
|
|
params['url'] = search_url.format(query=query)
|
|
|
|
return params
|
|
|
|
|
|
|
|
|
|
|
|
# get response from search-request
|
|
|
|
def response(resp):
|
|
|
|
results = []
|
|
|
|
|
|
|
|
dom = html.fromstring(resp.text)
|
|
|
|
|
2019-08-05 13:44:02 +00:00
|
|
|
for app in dom.xpath('//a[@class="package-header"]'):
|
|
|
|
app_url = app.xpath('./@href')[0]
|
|
|
|
app_title = extract_text(app.xpath('./div/h4[@class="package-name"]/text()'))
|
2021-12-27 08:26:22 +00:00
|
|
|
app_content = (
|
|
|
|
extract_text(app.xpath('./div/div/span[@class="package-summary"]')).strip()
|
|
|
|
+ ' - '
|
|
|
|
+ extract_text(app.xpath('./div/div/span[@class="package-license"]')).strip()
|
|
|
|
)
|
2024-05-12 15:52:52 +00:00
|
|
|
thumbnail = app.xpath('./img[@class="package-icon"]/@src')[0]
|
2019-08-05 13:44:02 +00:00
|
|
|
|
2024-05-12 15:52:52 +00:00
|
|
|
results.append({'url': app_url, 'title': app_title, 'content': app_content, 'thumbnail': thumbnail})
|
2016-03-26 21:50:44 +00:00
|
|
|
|
|
|
|
return results
|