From 3d05dc8571fcc8e7a36375f2d3fa7b9454eb51e9 Mon Sep 17 00:00:00 2001 From: ThisBirchWood Date: Wed, 26 Feb 2025 15:31:13 +0000 Subject: [PATCH] PATCH: Added check to see if stream ever published in /end_stream, otherwise errors occured --- web_server/blueprints/streams.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web_server/blueprints/streams.py b/web_server/blueprints/streams.py index ef816cc..4bb3246 100644 --- a/web_server/blueprints/streams.py +++ b/web_server/blueprints/streams.py @@ -173,7 +173,7 @@ def init_stream(): """ stream_key = request.form.get("name") - print(f"Stream initialization requested in nginx with key: {stream_key}") + print(f"Stream initialization requested in nginx with key: {stream_key}", flush=True) with Database() as db: # Check if valid stream key and user is allowed to stream @@ -314,7 +314,12 @@ def end_stream(): if not user_info: print("Unauthorized - No user found from stream key", flush=True) return "Unauthorized", 403 - + + # If stream never published, return + if not stream_info: + print("Stream never began", flush=True) + return "Stream ended", 200 + # Remove stream from database db.execute("""DELETE FROM streams WHERE user_id = ?""", (user_info["user_id"],))