[ARCH] Media API editions endpoint
This commit is contained in:
1 parent
3e41857068
commit
0848c84a68
1 file changed
+17
@@ -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()})
|
||||
|
||||
Reference in new issue
Block a user