[ARCH] Media API: explicit requests/continue/releases/recommendations statuses
lint / hygiene (push) Failing after 19s
lint / hygiene (pull_request) Failing after 22s
standard / check (pull_request) Successful in 9s

This commit is contained in:
architect committed 2026-11-26 23:45:37 +03:00
1 parent 1074479bc7
commit 68c35b4897
1 file changed
+27
+27
View File
@@ -40,6 +40,21 @@ def recent():
return out
def seerr(path):
keyfile = Path("/root/.seerr-key")
if not keyfile.exists():
return 503, {"ok": False, "error": "seerr_key_missing"}
req = urllib.request.Request(
"http://192.168.1.121:5055" + path,
headers={"X-Api-Key": keyfile.read_text().strip(), "Accept": "application/json"})
try:
with urllib.request.urlopen(req, timeout=8) as r:
return 200, json.load(r)
except urllib.error.HTTPError as e:
return (503 if e.code in (401, 403) else e.code), {
"ok": False, "error": "seerr_%s" % e.code}
def item(i):
qs = urllib.parse.urlencode({"Ids": i, "Fields": "Overview,ProductionYear,MediaSources"})
data = jf("/Items?" + qs)
@@ -166,6 +181,18 @@ class H(BaseHTTPRequestHandler):
except Exception as e:
self.out(502, {"ok": False, "error": str(e)[:300]})
return
if u.path == "/v1/media/requests":
code, body = seerr("/api/v1/request?take=20")
self.out(code, body)
return
if len(parts) == 4 and parts[:3] == ["v1", "media", "requests"]:
code, body = seerr("/api/v1/request/%s" % urllib.parse.quote(parts[3]))
self.out(code, body)
return
if u.path in ("/v1/media/continue", "/v1/media/releases", "/v1/media/recommendations"):
self.out(501, {"ok": False, "error": "not_configured",
"endpoint": u.path})
return
if u.path == "/v1/media/recent":
try:
self.out(200, {"ok": True, "items": recent()})