mirror of
https://github.com/searxng/searxng.git
synced 2026-06-14 22:06:52 +02:00
[feat] engines: add podchaser podcast engine (#6202)
- add podchaser podcast engine - the motivation is that podcastindex had to be removed, see #6140
This commit is contained in:
@@ -0,0 +1,62 @@
|
|||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"""Podchaser (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://www.podchaser.com",
|
||||||
|
"official_api_documentation": "https://www.podchaser.com/api",
|
||||||
|
"use_official_api": False,
|
||||||
|
"require_api_key": False,
|
||||||
|
"results": "JSON",
|
||||||
|
}
|
||||||
|
categories = []
|
||||||
|
paging = True
|
||||||
|
|
||||||
|
base_url = "https://api.podchaser.com"
|
||||||
|
page_size = 25
|
||||||
|
|
||||||
|
|
||||||
|
def request(query: str, params: "OnlineParams") -> None:
|
||||||
|
args = {
|
||||||
|
"filters[term]": query,
|
||||||
|
"limit": page_size,
|
||||||
|
"offset": (params["pageno"] - 1) * page_size,
|
||||||
|
"sort_direction": "desc",
|
||||||
|
"sort_order": "SORT_ORDER_RELEVANCE",
|
||||||
|
}
|
||||||
|
params["url"] = f"{base_url}/podcasts?{urlencode(args)}"
|
||||||
|
params["headers"]["Accept"] = "application/prs.podchaser.v2+json"
|
||||||
|
|
||||||
|
|
||||||
|
def response(resp: "SXNG_Response"):
|
||||||
|
res = EngineResults()
|
||||||
|
|
||||||
|
json_results: list[dict[str, str]] = resp.json()["entities"] # pyright: ignore[reportAny]
|
||||||
|
|
||||||
|
for result in json_results:
|
||||||
|
metadata = [f"{result['number_of_episodes']} episodes"]
|
||||||
|
if result["categories"]:
|
||||||
|
metadata.append(", ".join(c["text"] for c in result["categories"])) # pyright: ignore[reportArgumentType]
|
||||||
|
|
||||||
|
res.add(
|
||||||
|
res.types.MainResult(
|
||||||
|
url=result["feed_url"],
|
||||||
|
title=result["title"],
|
||||||
|
content=result["description"],
|
||||||
|
thumbnail=result["image_url"],
|
||||||
|
publishedDate=datetime.strptime(result["created_at"], "%Y-%m-%d %H:%M:%S"),
|
||||||
|
metadata=" | ".join(metadata),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return res
|
||||||
@@ -1817,6 +1817,11 @@ engines:
|
|||||||
# query_str: 'SELECT * from my_table WHERE my_column = %(query)s'
|
# query_str: 'SELECT * from my_table WHERE my_column = %(query)s'
|
||||||
# shortcut : psql
|
# shortcut : psql
|
||||||
|
|
||||||
|
- name: podchaser
|
||||||
|
engine: podchaser
|
||||||
|
shortcut: poc
|
||||||
|
disabled: true
|
||||||
|
|
||||||
- name: presearch
|
- name: presearch
|
||||||
engine: presearch
|
engine: presearch
|
||||||
search_type: search
|
search_type: search
|
||||||
|
|||||||
Reference in New Issue
Block a user