Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[feat] engines: add podchaser podcast engine (#6202)

Bnyro1184b3212fdd
diff --git a/searx/engines/podchaser.py b/searx/engines/podchaser.py
new file mode 100644
index 000000000..b95de7e85
--- /dev/null
+++ b/searx/engines/podchaser.py
@@ -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
diff --git a/searx/settings.yml b/searx/settings.yml
index 832ae4043..f9a342f20 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -1817,6 +1817,11 @@ engines:
# query_str: 'SELECT * from my_table WHERE my_column = %(query)s'
# shortcut : psql
+ - name: podchaser
+ engine: podchaser
+ shortcut: poc
+ disabled: true
+
- name: presearch
engine: presearch
search_type: search