Detect youtube ban

This commit is contained in:
insert 2024-12-14 13:13:48 -05:00
parent 9f2ab61ee7
commit 404328b07c
Signed by: insert
GPG key ID: A70775C389ACF105

View file

@ -151,8 +151,13 @@ def download_video(index):
ydl.download(queue[index]) ydl.download(queue[index])
retries = 0 retries = 0
sleep(2) #allow ytdlp to fully cleanup sleep(2) #allow ytdlp to fully cleanup
except Exception: except Exception as e:
print("handling youtube exception") 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 global failures
if retries % 2 == 1: if retries % 2 == 1:
queue.pop(index) queue.pop(index)
@ -560,7 +565,7 @@ async def videotimer():
@tasks.loop(seconds=20) @tasks.loop(seconds=20)
async def ensurewaiting(): async def ensurewaiting():
scene = obs.get_current_program_scene() scene = obs.get_current_program_scene()
if scene.scene_name == "waiting": if scene.scene_name == "waiting" or scene.scene_name == "banned":
return return
if scene.scene_name == "error" and len(os.listdir(full_dl_dir)) == 0: if scene.scene_name == "error" and len(os.listdir(full_dl_dir)) == 0:
obs.set_current_program_scene("waiting") obs.set_current_program_scene("waiting")
@ -574,8 +579,9 @@ async def ensurewaiting():
playing = obs.get_media_input_status("player") playing = obs.get_media_input_status("player")
if playing.media_cursor == None: if playing.media_cursor == None:
obs.set_current_program_scene("error") 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() loop = asyncio.get_running_loop()
propagate_queue(2)
await loop.run_in_executor(None, download_video, 0) await loop.run_in_executor(None, download_video, 0)
@tasks.loop(seconds=5) @tasks.loop(seconds=5)