mirror of
https://git.wownero.com/dsc/ircradio.git
synced 2024-08-15 01:03:15 +00:00
Websocket only sends new track (or updated name)
This commit is contained in:
parent
c43ad4bffd
commit
5e966b872c
1 changed files with 6 additions and 3 deletions
|
@ -113,7 +113,8 @@ async def user_library():
|
||||||
|
|
||||||
|
|
||||||
@app.websocket("/ws")
|
@app.websocket("/ws")
|
||||||
+async def np():
|
async def np():
|
||||||
|
last_song = ""
|
||||||
while True:
|
while True:
|
||||||
"""get current song from history"""
|
"""get current song from history"""
|
||||||
history = Radio.history()
|
history = Radio.history()
|
||||||
|
@ -124,7 +125,9 @@ async def user_library():
|
||||||
song = history[0]
|
song = history[0]
|
||||||
val = song.title
|
val = song.title
|
||||||
|
|
||||||
|
if val != last_song:
|
||||||
data = json.dumps({"now_playing": val})
|
data = json.dumps({"now_playing": val})
|
||||||
|
|
||||||
await websocket.send(f"{data}")
|
await websocket.send(f"{data}")
|
||||||
|
|
||||||
|
last_song = val
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
|
|
Loading…
Reference in a new issue