Files
searxng/searx/engines/fyyd.py
Onev 9e25585aec [refactor] engines: use datetime.fromisoformat instead of datetime.strptime where possible (#6394)
Refactor engines that parse ISO 8601 dates with strptime to use
fromisoformat instead. In most cases this is a direct replacement of
strptime(text, "format") with fromisoformat(text).

For engines where the source has a trailing "Z" that strptime consumed
as a literal (e.g. "%Y-%m-%dT%H:%M:%S.%fZ" in huggingface.py), add
rstrip("Z") to keep the output naive and preserve the existing behavior.

In sogou.py the date is extracted with a regular expression, which can
yield strings like "2026-7-11". strptime accepts this via its format
string, but fromisoformat does not. To preserve the existing behavior
and satisfy the format fromisoformat expects, add zero-padding for the
month and day.

Closes: #6098
---------
Signed-off-by: OneVth <onebrotravel@gmail.com>
2026-07-13 17:46:56 +02:00

56 lines
1.4 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""Fyyd (podcasts)"""
import typing as t
from datetime import datetime
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 = {
"website": "https://fyyd.de",
"official_api_documentation": "https://github.com/eazyliving/fyyd-api",
"use_official_api": True,
"require_api_key": False,
"results": "JSON",
}
categories = []
paging = True
base_url = "https://api.fyyd.de"
page_size = 10
def request(query: str, params: "OnlineParams") -> None:
args = {
"term": query,
"count": page_size,
"page": params["pageno"] - 1,
}
params["url"] = f"{base_url}/0.2/search/podcast?{urlencode(args)}"
def response(resp: "SXNG_Response"):
res = EngineResults()
json_results: list[dict[str, str]] = resp.json()["data"] # pyright: ignore[reportAny]
for result in json_results:
res.add(
res.types.MainResult(
url=result["htmlURL"],
title=result["title"],
content=result["description"],
thumbnail=result["smallImageURL"],
publishedDate=datetime.fromisoformat(result["status_since"]),
metadata=f"Rank: {result['rank']} || {result['episode_count']} episodes",
)
)
return res