mirror of
https://github.com/myronblair/kino-app
synced 2026-06-30 17:50:16 -05:00
auto-commit for 14921357-f5e2-4aba-b4c1-a07a52c800cc
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""Radarr v3 API client. https://radarr.video/docs/api/"""
|
||||
import requests
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
|
||||
def _h(api_key: str) -> dict:
|
||||
return {"X-Api-Key": api_key, "Content-Type": "application/json"}
|
||||
|
||||
|
||||
def list_movies(base_url: str, api_key: str) -> List[Dict]:
|
||||
base_url = base_url.rstrip("/")
|
||||
r = requests.get(f"{base_url}/api/v3/movie", headers=_h(api_key), timeout=20)
|
||||
r.raise_for_status()
|
||||
data = r.json() or []
|
||||
out = []
|
||||
for m in data:
|
||||
poster = ""
|
||||
for img in m.get("images", []) or []:
|
||||
if img.get("coverType") == "poster":
|
||||
poster = img.get("remoteUrl") or img.get("url") or ""
|
||||
break
|
||||
movie_file = m.get("movieFile") or {}
|
||||
out.append({
|
||||
"radarr_id": m["id"],
|
||||
"title": m.get("title") or "",
|
||||
"year": m.get("year"),
|
||||
"overview": m.get("overview") or "",
|
||||
"has_file": bool(m.get("hasFile")),
|
||||
"file_path": movie_file.get("path") if movie_file else None,
|
||||
"poster_url": poster,
|
||||
"tmdb_id": m.get("tmdbId"),
|
||||
})
|
||||
return out
|
||||
|
||||
|
||||
def test_connection(base_url: str, api_key: str) -> bool:
|
||||
base_url = base_url.rstrip("/")
|
||||
try:
|
||||
r = requests.get(f"{base_url}/api/v3/system/status", headers=_h(api_key), timeout=10)
|
||||
return r.ok
|
||||
except Exception:
|
||||
return False
|
||||
Reference in New Issue
Block a user