make random picker avoid same stream 2x in a row

This commit is contained in:
Micha Albert 2024-07-28 23:55:30 +00:00
parent 60c7f70fe5
commit 5582a0ffae

View file

@ -27,8 +27,13 @@ async def update_active():
for stream in streams: for stream in streams:
if stream["ready"]: if stream["ready"]:
active_streams.append(stream) active_streams.append(stream)
active_stream = choice(active_streams)["name"] try:
new_stream = choice(active_streams)["name"]
while new_stream == active_stream:
new_stream = choice(active_streams)["name"]
active_stream = new_stream
except Exception:
pass
async def init_active_update_task(): async def init_active_update_task():
global active_stream global active_stream