From 404328b07c20c88c1c05ebbcf25c6986553eb9df Mon Sep 17 00:00:00 2001 From: insert Date: Sat, 14 Dec 2024 13:13:48 -0500 Subject: [PATCH] Detect youtube ban --- newbot.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/newbot.py b/newbot.py index bf7dbbe..8b602d0 100644 --- a/newbot.py +++ b/newbot.py @@ -151,8 +151,13 @@ def download_video(index): ydl.download(queue[index]) retries = 0 sleep(2) #allow ytdlp to fully cleanup - except Exception: + except Exception as e: print("handling youtube exception") + if "Sign in to confirm" in str(e): + print("youtube ban detected") + #This is the worst possible case and therefore all activity must halt + obs.set_current_program_scene("banned") + return global failures if retries % 2 == 1: queue.pop(index) @@ -560,7 +565,7 @@ async def videotimer(): @tasks.loop(seconds=20) async def ensurewaiting(): scene = obs.get_current_program_scene() - if scene.scene_name == "waiting": + if scene.scene_name == "waiting" or scene.scene_name == "banned": return if scene.scene_name == "error" and len(os.listdir(full_dl_dir)) == 0: obs.set_current_program_scene("waiting") @@ -574,8 +579,9 @@ async def ensurewaiting(): playing = obs.get_media_input_status("player") if playing.media_cursor == None: obs.set_current_program_scene("error") - if len(os.listdir(full_dl_dir)) == 0 and len(queue) >= 1: #just in case + if len(os.listdir(full_dl_dir)) == 0 and sqllen() >= 1: #just in case loop = asyncio.get_running_loop() + propagate_queue(2) await loop.run_in_executor(None, download_video, 0) @tasks.loop(seconds=5)