[ARCH] Media API editions endpoint
lint / hygiene (push) Failing after 20s
lint / hygiene (pull_request) Failing after 16s
standard / check (pull_request) Successful in 7s

This commit is contained in:
architect committed 2026-11-26 23:43:03 +03:00
1 parent 3e41857068
commit 0848c84a68
1 file changed
+17
+17
View File
@@ -57,6 +57,17 @@ def item(i):
}
def editions(i):
qs = urllib.parse.urlencode({"Ids": i, "Fields": "MediaSources"})
data = jf("/Items?" + qs)
items = data.get("Items") or []
if not items:
raise RuntimeError("item not found")
src = items[0].get("MediaSources") or []
return [{"id": s.get("Id"), "name": s.get("Name"), "container": s.get("Container"),
"size": s.get("Size"), "bitrate": s.get("Bitrate")} for s in src]
def search(q):
if not q.strip():
return []
@@ -149,6 +160,12 @@ class H(BaseHTTPRequestHandler):
except Exception as e:
self.out(502, {"ok": False, "error": str(e)[:300]})
return
if len(parts) == 5 and parts[:3] == ["v1", "media", "works"] and parts[4] == "editions":
try:
self.out(200, {"ok": True, "editions": editions(parts[3])})
except Exception as e:
self.out(502, {"ok": False, "error": str(e)[:300]})
return
if u.path == "/v1/media/recent":
try:
self.out(200, {"ok": True, "items": recent()})