From 5582a0ffaec3b3e005f569e2340660ecd422d9e0 Mon Sep 17 00:00:00 2001 From: Micha Albert Date: Sun, 28 Jul 2024 23:55:30 +0000 Subject: [PATCH] make random picker avoid same stream 2x in a row --- stream/backend/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stream/backend/main.py b/stream/backend/main.py index 746f052..a339d2a 100644 --- a/stream/backend/main.py +++ b/stream/backend/main.py @@ -27,8 +27,13 @@ async def update_active(): for stream in streams: if stream["ready"]: 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(): global active_stream