mirror of
https://github.com/searxng/searxng.git
synced 2026-05-24 03:44:31 +02:00
[mod] engine fyyd: typing added, no functional change (#6103)
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
+31
-24
@@ -1,15 +1,23 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
"""Fyyd (podcasts)"""
|
"""Fyyd (podcasts)"""
|
||||||
|
|
||||||
|
import typing as t
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
|
from searx.result_types import EngineResults
|
||||||
|
|
||||||
|
if t.TYPE_CHECKING:
|
||||||
|
from searx.extended_types import SXNG_Response
|
||||||
|
from searx.search.processors import OnlineParams
|
||||||
|
|
||||||
about = {
|
about = {
|
||||||
'website': 'https://fyyd.de',
|
"website": "https://fyyd.de",
|
||||||
'official_api_documentation': 'https://github.com/eazyliving/fyyd-api',
|
"official_api_documentation": "https://github.com/eazyliving/fyyd-api",
|
||||||
'use_official_api': True,
|
"use_official_api": True,
|
||||||
'require_api_key': False,
|
"require_api_key": False,
|
||||||
'results': 'JSON',
|
"results": "JSON",
|
||||||
}
|
}
|
||||||
categories = []
|
categories = []
|
||||||
paging = True
|
paging = True
|
||||||
@@ -18,31 +26,30 @@ base_url = "https://api.fyyd.de"
|
|||||||
page_size = 10
|
page_size = 10
|
||||||
|
|
||||||
|
|
||||||
def request(query, params):
|
def request(query: str, params: "OnlineParams") -> None:
|
||||||
args = {
|
args = {
|
||||||
'term': query,
|
"term": query,
|
||||||
'count': page_size,
|
"count": page_size,
|
||||||
'page': params['pageno'] - 1,
|
"page": params["pageno"] - 1,
|
||||||
}
|
}
|
||||||
params['url'] = f"{base_url}/0.2/search/podcast?{urlencode(args)}"
|
params["url"] = f"{base_url}/0.2/search/podcast?{urlencode(args)}"
|
||||||
return params
|
|
||||||
|
|
||||||
|
|
||||||
def response(resp):
|
def response(resp: "SXNG_Response"):
|
||||||
results = []
|
res = EngineResults()
|
||||||
|
|
||||||
json_results = resp.json()['data']
|
json_results: list[dict[str, str]] = resp.json()["data"] # pyright: ignore[reportAny]
|
||||||
|
|
||||||
for result in json_results:
|
for result in json_results:
|
||||||
results.append(
|
res.add(
|
||||||
{
|
res.types.MainResult(
|
||||||
'url': result['htmlURL'],
|
url=result["htmlURL"],
|
||||||
'title': result['title'],
|
title=result["title"],
|
||||||
'content': result['description'],
|
content=result["description"],
|
||||||
'thumbnail': result['smallImageURL'],
|
thumbnail=result["smallImageURL"],
|
||||||
'publishedDate': datetime.strptime(result['status_since'], '%Y-%m-%d %H:%M:%S'),
|
publishedDate=datetime.strptime(result["status_since"], "%Y-%m-%d %H:%M:%S"),
|
||||||
'metadata': f"Rank: {result['rank']} || {result['episode_count']} episodes",
|
metadata=f"Rank: {result['rank']} || {result['episode_count']} episodes",
|
||||||
}
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return results
|
return res
|
||||||
|
|||||||
Reference in New Issue
Block a user