tools.prowlarr_search module
Search torrent indexers via a local Prowlarr instance (Docker *arr stack).
- async tools.prowlarr_search.run(query, max_results=5, ctx=None)[source]
Search every enabled Prowlarr indexer for a query and return ranked JSON.
Entry point for the
search_prowlarrtool. It authorizes the caller, reads the Prowlarr endpoint from config, performs one unfiltered interactive search across all enabled indexers, then ranks the merged releases by seeders and truncates tomax_resultsbefore returning them as a JSON string.It gates on
_check_web_search_access()(theWEB_SEARCHprivilege, resolved against Redis), readsprowlarr_base_urlandprowlarr_api_keyfromctx.config, normalises the base URL via_normalize_base(), and over-fetches using_fetch_limit_for_sort(). The actual call is an asyncaiohttpGET to/api/v1/search(120s timeout,X-Api-Keyheader); the JSON response is ranked and trimmed by_sort_and_limit_releases(). Network and unexpected errors are caught, logged vialogger.exception, and folded into an error payload rather than propagated. No module state is mutated.Registered via the single-tool module contract (
TOOL_NAME/run) and dispatched bytool_loader.load_tools; no direct in-repo Python callers.- Parameters:
query (
str) – Search keywords / release title; must be non-empty.max_results (
int) – Releases to return after seeder-ranking; coerced to an int and capped at 200 (default 5).ctx (
ToolContext|None) – The tool context supplyinguser_id,redis, andconfig(Prowlarr URL and API key).
- Returns:
A JSON array of the top releases on success, or a JSON
{"error": ...}string when authorization fails, the query is empty, config is missing the URL/key, Prowlarr returns a non-200 or invalid JSON, or a network/unexpected error occurs.- Return type: