Control PC playback through interactive Live Activity intents

This commit is contained in:
2026-09-13 11:40:23 +03:00
parent fcc66aa328
commit 1e02247cbe
14 changed files with 266 additions and 32 deletions
+20
View File
@@ -67,11 +67,25 @@ class Handler(http.server.BaseHTTPRequestHandler):
def snapshot(self, token):
result = dict(state)
if token.startswith("live-"):
with counts_lock:
commands = counts.get((token, "command"), 0)
result["title"] = "Track " + str(commands)
if token == "live-unsupported":
result["capabilities"] = {key: False for key in result["capabilities"]}
result["artworkId"] = "A" * 64 if token in ("artwork", "artwork-fail", "late-art") else None
return result
def do_POST(self):
body = json.loads(self.rfile.read(int(self.headers.get("Content-Length", "0"))))
token = self.headers.get("Authorization", "").removeprefix("Bearer ")
if token.startswith("live-"):
count(token, "command")
if token == "live-reject":
self.reply(200, {"success": False, "code": "unsupported", "message": "Rejected"})
else:
self.reply(200, {"success": True, "code": "ok", "message": "OK"})
return
if self.path == "/v1/pair":
code = body.get("code")
if code == "33333333":
@@ -86,6 +100,12 @@ class Handler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
token = self.headers.get("Authorization", "").removeprefix("Bearer ")
number = count(token, self.path)
if token == "live-refresh-fail" and self.path == "/v1/state":
with counts_lock:
commands = counts.get((token, "command"), 0)
if commands:
self.reply(503, {})
return
if token == "revoked":
self.reply(401, {})
return