removed bunch of old code, added /init bunch of cleanups
Build and Push Agent API / build (push) Successful in 4s

This commit is contained in:
2026-05-25 18:07:01 +02:00
parent f28f0d41ec
commit f21676eafd
13 changed files with 119 additions and 792 deletions
+6 -25
View File
@@ -565,26 +565,12 @@ async def _discover(args: dict) -> ToolResult:
r.raise_for_status()
results = r.json().get("results", [])
desc = genre
elif studio:
# /discover/studio/{studioId} requires a numeric TMDB studio ID.
# Fall back to searching by name via /search.
desc = studio
search_query = studio
elif studio or keyword:
# Both use /search with free-text query (studio needs a numeric TMDB
# studio ID not available here, so fall back to name search).
desc = studio or keyword
endpoint = "/api/v1/search"
params["query"] = search_query
if language:
params["language"] = language
async with _client() as c:
r = await c.get(endpoint, params=params)
r.raise_for_status()
results = r.json().get("results", [])
# Filter to requested media type
results = [item for item in results if item.get("mediaType") == kind]
elif keyword:
# Free-text keyword → use /search, filtered by mediaType
desc = keyword
endpoint = "/api/v1/search"
params["query"] = keyword
params["query"] = desc
if language:
params["language"] = language
async with _client() as c:
@@ -616,7 +602,6 @@ async def _request_media(args: dict) -> ToolResult:
async with _client() as c:
# --- Fast-path: TMDb ID known — confirm the title and request directly ---
if tmdb_id:
# Quick lookup to get the correct title for the confirmation message
detail_r = await c.get(f"/api/v1/{kind}/{tmdb_id}")
if detail_r.status_code == 200:
detail = detail_r.json()
@@ -626,11 +611,6 @@ async def _request_media(args: dict) -> ToolResult:
or detail.get("firstAirDate", "")[:4]
or "?"
)
else:
# Detail lookup failed — fall back to title search
pass
if detail_r.status_code == 200:
# Submit directly with the known TMDb ID
request_body: dict = {"mediaType": kind, "mediaId": tmdb_id}
if kind == "tv":
@@ -651,6 +631,7 @@ async def _request_media(args: dict) -> ToolResult:
f"❌ Failed to request **{media_title}** ({media_year}). "
f"Seerr responded with status {req_r.status_code}: {req_r.text[:500]}"
)
# Detail lookup failed — fall through to slow-path title search
# --- Slow-path: search by title ---
r = await c.get("/api/v1/search", params={"query": quote(title), "page": 1})