Only require one video to start playback
This commit is contained in:
parent
ffcf1b594c
commit
8d63c013fb
1 changed files with 13 additions and 5 deletions
18
newbot.py
18
newbot.py
|
@ -79,7 +79,7 @@ def propagate_queue(times):
|
||||||
res = cur.execute(f"SELECT ROWID,link FROM queue WHERE hasplayed = false " + ("ORDER BY RANDOM() " if shuffle else "") + f"LIMIT {times}")
|
res = cur.execute(f"SELECT ROWID,link FROM queue WHERE hasplayed = false " + ("ORDER BY RANDOM() " if shuffle else "") + f"LIMIT {times}")
|
||||||
for rowid,link in res.fetchall():
|
for rowid,link in res.fetchall():
|
||||||
if len(queue) == 2:
|
if len(queue) == 2:
|
||||||
print("the queue is already propagated refusing to evaluate!")
|
print("the queue is already propagated, exiting early")
|
||||||
return
|
return
|
||||||
elif len(queue) > 2:
|
elif len(queue) > 2:
|
||||||
print(f"The queue is larger than two videos this WILL cause issues: {queue}")
|
print(f"The queue is larger than two videos this WILL cause issues: {queue}")
|
||||||
|
@ -235,13 +235,15 @@ def on_media_input_playback_ended(data):
|
||||||
global vidcounter
|
global vidcounter
|
||||||
try:
|
try:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
propagate_queue(1)
|
propagate_queue(2)
|
||||||
except IndexError as e:
|
except IndexError as e:
|
||||||
print(f"Video ended but somehow it wasn't in the queue? Resetting {e}")
|
print(f"Video ended but somehow it wasn't in the queue? Resetting {e}")
|
||||||
obs.set_current_program_scene("waiting")
|
obs.set_current_program_scene("waiting")
|
||||||
skip_list.clear()
|
skip_list.clear()
|
||||||
if not queue:
|
if not queue:
|
||||||
|
print("queue is now empty")
|
||||||
if sqllen() >= 1:
|
if sqllen() >= 1:
|
||||||
|
print("alternative download triggered")
|
||||||
propagate_queue(2)
|
propagate_queue(2)
|
||||||
download_video(0) #will be noticeably slow but this should not happen
|
download_video(0) #will be noticeably slow but this should not happen
|
||||||
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
|
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
|
||||||
|
@ -318,12 +320,17 @@ async def play(inter: disnake.AppCmdInter, link: str):
|
||||||
""")
|
""")
|
||||||
con.commit()
|
con.commit()
|
||||||
await inter.edit_original_response(f"added to queue!")
|
await inter.edit_original_response(f"added to queue!")
|
||||||
if (not os.path.isfile(f"{vid_dir}/{vidcounter}.mp4")) and sqllen() > 1 and len(queue) == 0:
|
scene = obs.get_current_program_scene()
|
||||||
|
if (not os.path.isfile(f"{vid_dir}/{vidcounter}.mp4")) and scene.scene_name == "waiting" and sqllen() >= 1 and len(queue) == 0:
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
queue.clear() #safety
|
#queue.clear() #safety
|
||||||
propagate_queue(2)
|
propagate_queue(2)
|
||||||
print(queue)
|
|
||||||
await loop.run_in_executor(None, cold_run)
|
await loop.run_in_executor(None, cold_run)
|
||||||
|
elif (not os.path.isfile(f"{vid_dir}/{vidcounter+1}.mp4")) and sqllen() >= 1 and len(queue) == 1:
|
||||||
|
loop = asyncio.get_running_loop()
|
||||||
|
propagate_queue(2)
|
||||||
|
await loop.run_in_executor(None, download_video, 1)
|
||||||
|
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
await inter.edit_original_response(f"This bot only accepts youtube links")
|
await inter.edit_original_response(f"This bot only accepts youtube links")
|
||||||
|
@ -613,6 +620,7 @@ async def ensurewaiting():
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
propagate_queue(2)
|
propagate_queue(2)
|
||||||
await loop.run_in_executor(None, download_video, 0)
|
await loop.run_in_executor(None, download_video, 0)
|
||||||
|
obs.set_current_program_scene("youtube")
|
||||||
|
|
||||||
@tasks.loop(seconds=5)
|
@tasks.loop(seconds=5)
|
||||||
async def titlehandler():
|
async def titlehandler():
|
||||||
|
|
Loading…
Reference in a new issue