mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-07-29 15:29:14 +02:00
make ws api simpler
This commit is contained in:
@@ -284,10 +284,6 @@
|
||||
const d = msg.data || {};
|
||||
if(d.track) applyProgressState(d.track);
|
||||
if(d.dirs) updateDirs(d.dirs);
|
||||
if(d.rds) {
|
||||
const rt = (d.rds?.rt) ?? "";
|
||||
document.getElementById("rds-text").textContent = rt ?? "";
|
||||
}
|
||||
} else if (msg.event === "rds") {
|
||||
const rt = (msg.data?.rt) ?? "";
|
||||
document.getElementById("rds-text").textContent = rt ?? "";
|
||||
|
||||
+2
-3
@@ -16,13 +16,12 @@ async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: mult
|
||||
try:
|
||||
initial = {
|
||||
"track": json.loads(shared_data.get("track", "{}")),
|
||||
"progress": json.loads(shared_data.get("progress", "{}")),
|
||||
"dirs": {"files": [i.name for i in list(MAIN_PATH_DIR.iterdir()) if i.is_file()], "dirs": [i.name for i in list(MAIN_PATH_DIR.iterdir()) if i.is_dir()], "base": str(MAIN_PATH_DIR)},
|
||||
"rds": json.loads(shared_data.get("rds", "{}"))
|
||||
}
|
||||
except Exception: initial = {"track": {}, "progress": {}, "dirs": {}, "rds": {}}
|
||||
except Exception: initial = {"track": {}, "dirs": {}}
|
||||
await websocket.send(json.dumps({"event": "state", "data": initial}))
|
||||
await websocket.send(json.dumps({"event": "playlist", "data": json.loads(shared_data.get("playlist", "[]"))}))
|
||||
await websocket.send(json.dumps({"event": "rds", "data": json.loads(shared_data.get("rds", "{}"))}))
|
||||
|
||||
async for raw in websocket:
|
||||
try: msg: dict = json.loads(raw)
|
||||
|
||||
Reference in New Issue
Block a user