Compare commits

..

No commits in common. "a35f66c387471af438930b96a9f1cfd9b3e18f77" and "8d63c013fb9dd06c277563e7226779c3c6fb86e2" have entirely different histories.

2 changed files with 111 additions and 173 deletions

View file

@ -8,5 +8,4 @@ MAX_QUEUE="5"
ALLOW_SKIP="TRUE" ALLOW_SKIP="TRUE"
PERMANENT_MAX_QUEUE="FALSE" PERMANENT_MAX_QUEUE="FALSE"
LOCK_SHUFFLE="FALSE" LOCK_SHUFFLE="FALSE"
USE_PROXY="TRUE MEANING YOU HAVE TO EDIT THE PROXIES LIST IN THE FILE OR FALSE" PROXY="socks5://your-proxy-here-or-comment-out-the-line-in-newbot.py"
BLOCK_REGEX=""

277
newbot.py
View file

@ -15,9 +15,8 @@ from disnake.ext import commands, tasks
from disnake import TextInputStyle from disnake import TextInputStyle
import asyncio import asyncio
from dotenv import load_dotenv from dotenv import load_dotenv
import os, sys, random import os, sys
import datetime import datetime
import re
import logging import logging
import math import math
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
@ -37,7 +36,6 @@ shuffle = True
retries = 0 retries = 0
failures = 0 failures = 0
vidcounter = 0 vidcounter = 0
proxies = []
temp_dir = TemporaryDirectory() temp_dir = TemporaryDirectory()
vid_dir = Path(temp_dir.name) vid_dir = Path(temp_dir.name)
download_dir = TemporaryDirectory() download_dir = TemporaryDirectory()
@ -45,118 +43,31 @@ full_dl_dir = Path(download_dir.name)
vid_details = {"title": "", "channel": ""} vid_details = {"title": "", "channel": ""}
con = sqlite3.connect(os.getenv("QUEUE_PATH","queue.db"), check_same_thread=False) con = sqlite3.connect(os.getenv("QUEUE_PATH","queue.db"), check_same_thread=False)
cur = con.cursor() cur = con.cursor()
options = Options()
options.add_argument("--headless")
driver = webdriver.Firefox(options=options)
print("Getting potoken from firefox...")
ydl = None driver.get("https://www.youtube.com/embed/aqz-KE-bpKQ")
def initytdl(): elem = WebDriverWait(driver, 8, 0.2, None).until(lambda x: x.find_element(By.CLASS_NAME, "html5-video-player"))
global ydl sleep(1)
if ydl: elem.click()
ydl.close() sleep(2)
if os.getenv("USE_PROXY","FALSE") == "FALSE": for r in driver.requests:
obs.set_current_program_scene("banned") if "https://www.youtube.com/youtubei/v1/player" in r.url:
ydl = None #In case of any rouge downloaders potoken = json.loads(r.body)['serviceIntegrityDimensions']["poToken"]
con.close() break
return driver.get("https://youtube.com")
options = Options() cookiesstr = to_netscape_string(driver.get_cookies())
options.add_argument("--headless") with open("cookies.txt", 'w') as f:
if os.getenv("USE_PROXY","FALSE") == "TRUE": f.write(f'# Netscape HTTP Cookie File\n# https://curl.haxx.se/rfc/cookie_spec.html\n# This is a generated file! Do not edit.\n\n{cookiesstr}')
if not proxies: driver.close()
obs.set_current_program_scene("banned") print(f"Success! Potoken is {potoken}")
ydl = None #In case of any rouge downloaders
con.close()
return
index = random.randrange(len(proxies))
proxy = proxies[index]
proxies.pop(index)
proxyoptions = {
'proxy': {
'http': proxy,
'https': proxy,
'no_proxy': 'localhost,127.0.0.1'
}
}
driver = webdriver.Firefox(options=options,seleniumwire_options=proxyoptions)
else:
driver = webdriver.Firefox(options=options)
proxy = ""
print("Getting potoken from firefox...")
try:
driver.get("https://www.youtube.com/embed/aqz-KE-bpKQ")
except Exception:
driver.close()
initytdl()
return
elem = WebDriverWait(driver, 8, 0.2, None).until(lambda x: x.find_element(By.CLASS_NAME, "html5-video-player"))
sleep(1)
elem.click()
sleep(3)
try:
for r in driver.requests:
if "googlevideo.com" in r.url:
f = re.compile("pot=.+?(?=&)")
gvtoken = f.findall(r.url)[0][4:]
if "https://www.youtube.com/youtubei/v1/player" in r.url:
potoken = json.loads(r.body)['serviceIntegrityDimensions']["poToken"]
except IndexError:
print("Youtube didn't send us a token, trying again")
initytdl()
return
driver.get("https://youtube.com")
cookiesstr = to_netscape_string(driver.get_cookies())
with open("cookies.txt", 'w') as f:
f.write(f'# Netscape HTTP Cookie File\n# https://curl.haxx.se/rfc/cookie_spec.html\n# This is a generated file! Do not edit.\n\n{cookiesstr}')
driver.quit()
print(f"Success! Potoken is {potoken}\nGvstoken is {gvtoken}")
ydl_opts = {
'match_filter': video_check,
'hls_prefer_native': True,
'extract_flat': 'discard_in_playlist',
'cookiefile': f'cookies.txt',
'extractor_args': {'youtube': {'player_client': ['web', 'mweb', 'default'],
'po_token': [f'web.gvs+{gvtoken}',f'web.player+{potoken}',f'mweb.gvs+{gvtoken}',f'mweb.player+{potoken}']}},
'format': 'bestvideo[height<=1080][vcodec!*=av01][ext=mp4]+bestaudio[abr<=256][ext=m4a]/best[ext=mp4]/best',
'fragment_retries': 10,
'noplaylist': True,
'restrictfilenames': True,
'source_address': '0.0.0.0',
'concurrent_fragment_downloads': 3,
'paths': {'home': f'{vid_dir}', 'temp': f'{full_dl_dir}'},
'outtmpl': {'default': f'999zznext'},
'postprocessors': [{'api': 'https://sponsor.ajay.app',
'categories': {'sponsor', 'selfpromo'},
'key': 'SponsorBlock',
'when': 'after_filter'},
{'force_keyframes': False,
'key': 'ModifyChapters',
'remove_chapters_patterns': [],
'remove_ranges': [],
'remove_sponsor_segments': {'sponsor', 'selfpromo'},
'sponsorblock_chapter_title': '[SponsorBlock]: '
'%(category_names)l'},
{'key': 'FFmpegConcat',
'only_multi_video': True,
'when': 'playlist'},
{'format': 'vtt',
'key': 'FFmpegSubtitlesConvertor',
'when': 'before_dl'},
{'already_have_subtitle': False,
'key': 'FFmpegEmbedSubtitle'}],
'proxy': f'{proxy}',
'subtitlesformat': 'vtt',
'subtitleslangs': ['en.*'],
'writesubtitles': True,
'retries': 10,
}
ydl = yt_dlp.YoutubeDL(ydl_opts)
if os.getenv("USE_PROXY","FALSE") == "TRUE":
print(f"Connected on {proxy}")
return
def countuser(usrid): def countuser(usrid):
res = cur.execute(f"SELECT ROWID FROM queue WHERE " + ("hasplayed = false AND " if not (os.getenv("PERMANENT_MAX_QUEUE","FALSE") == "TRUE") else "") + f"user = {usrid}") res = cur.execute(f"SELECT ROWID FROM queue WHERE " + ("hasplayed = false AND " if not (os.getenv("PERMANENT_MAX_QUEUE","FALSE") == "TRUE") else "") + f"user = {usrid}")
rowid = res.fetchall() rowid = res.fetchall()
print(len(rowid))
return len(rowid) return len(rowid)
def sqllen(): def sqllen():
@ -184,14 +95,59 @@ def video_check(info, *, incomplete):
vid_details["channel"] = info.get("channel") vid_details["channel"] = info.get("channel")
print(info.get("channel")) print(info.get("channel"))
print(info.get("title")) print(info.get("title"))
banned_video = re.compile(os.getenv("BLOCK_REGEX",""), re.IGNORECASE).findall(f"{vid_details['title']} {vid_details['channel']}") if duration and duration >= ((float(os.getenv("MAX_MIN")) * 60) + 480):
if (duration and duration >= ((float(os.getenv("MAX_MIN")) * 60) + 480)) or banned_video: queue.pop(0)
return "video too long" #TODO why is this an issue if its the second video played propagate_queue(1)
skip_list.clear()
if queue:
ydl.download(queue[0])
return "video too long... :("
ydl_opts = {
'match_filter': video_check,
'hls_prefer_native': True,
'extract_flat': 'discard_in_playlist',
'cookiefile': f'cookies.txt',
'extractor_args': {'youtube': {'player_client': ['web', 'default'],
'po_token': [f'web+{potoken}']}},
'format': 'bestvideo[height<=1080][vcodec!*=av01][ext=mp4]+bestaudio[abr<=256][ext=m4a]/best[ext=mp4]/best',
'fragment_retries': 10,
'noplaylist': True,
'restrictfilenames': True,
'source_address': '0.0.0.0',
'concurrent_fragment_downloads': 3,
'paths': {'home': f'{vid_dir}', 'temp': f'{full_dl_dir}'},
'outtmpl': {'default': f'999zznext'},
'postprocessors': [{'api': 'https://sponsor.ajay.app',
'categories': {'sponsor', 'selfpromo'},
'key': 'SponsorBlock',
'when': 'after_filter'},
{'force_keyframes': False,
'key': 'ModifyChapters',
'remove_chapters_patterns': [],
'remove_ranges': [],
'remove_sponsor_segments': {'sponsor', 'selfpromo'},
'sponsorblock_chapter_title': '[SponsorBlock]: '
'%(category_names)l'},
{'key': 'FFmpegConcat',
'only_multi_video': True,
'when': 'playlist'},
{'format': 'vtt',
'key': 'FFmpegSubtitlesConvertor',
'when': 'before_dl'},
{'already_have_subtitle': False,
'key': 'FFmpegEmbedSubtitle'}],
'proxy': f'{os.getenv("PROXY")}',
'subtitlesformat': 'vtt',
'subtitleslangs': ['en.*'],
'writesubtitles': True,
'retries': 10,
}
#logging.basicConfig(level=logging.DEBUG)
ydl = yt_dlp.YoutubeDL(ydl_opts)
obs = obsws_python.ReqClient() obs = obsws_python.ReqClient()
obse = obsws_python.EventClient() obse = obsws_python.EventClient()
initytdl()
intents = disnake.Intents.all() intents = disnake.Intents.all()
intents.message_content = False intents.message_content = False
bot = commands.Bot(intents=intents, command_prefix=".", test_guilds=[int(os.getenv("GUILD_ID"))]) bot = commands.Bot(intents=intents, command_prefix=".", test_guilds=[int(os.getenv("GUILD_ID"))])
@ -210,58 +166,35 @@ async def on_ready():
videotimer.start() videotimer.start()
ensurewaiting.start() ensurewaiting.start()
titlehandler.start() titlehandler.start()
if (not os.path.isfile(f"{vid_dir}/{vidcounter}.mp4")) and sqllen() >= 1: if (not os.path.isfile(f"{vid_dir}/{vidcounter}.mp4")) and sqllen() > 1:
print("predefined queue!") print("predefined queue!")
propagate_queue(2) propagate_queue(2)
loop = asyncio.get_running_loop() loop = asyncio.get_running_loop()
await loop.run_in_executor(None, cold_run) await loop.run_in_executor(None, cold_run)
if len(queue) > 1:
download_video(1)
downloading = False
def download_video(index,bypass=False,renameoffset=1): def download_video(index):
global retries global retries
global downloading
if bypass:
for filename in os.listdir(full_dl_dir):
filepath = os.path.join(full_dl_dir, filename)
os.remove(filepath)
if downloading and not bypass:
print("download defered, waiting")
while downloading and not bypass:
pass
while len(os.listdir(full_dl_dir)) != 0: while len(os.listdir(full_dl_dir)) != 0:
pass pass
try: try:
downloading = True
ydl.download(queue[index]) ydl.download(queue[index])
sleep(2) #allow ytdlp to fully cleanup
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+renameoffset}.mp4")
downloading = False
retries = 0 retries = 0
return sleep(2) #allow ytdlp to fully cleanup
except Exception as e: except Exception as e:
print("handling youtube exception") print("handling youtube exception")
global failures if "Sign in to confirm" in str(e) or "forbidden" in str(e).lower():
if "not a bot" in str(e).lower() or "forbidden" in str(e).lower() or failures >= 4:
print("youtube ban detected") print("youtube ban detected")
initytdl() #This is the worst possible case and therefore all activity must halt
download_video(index,True) obs.set_current_program_scene("banned")
failures = 0
return return
if "no such file or directory" in str(e).lower(): #Thanks for the silent fail ytdlp global failures
if retries % 2 == 1:
queue.pop(index) queue.pop(index)
propagate_queue(1) propagate_queue(1)
else: failures = failures + 1
if retries % 2 == 1: retries = retries + 1
queue.pop(index) download_video(index)
propagate_queue(1)
failures = failures + 1
retries = retries + 1
if len(queue) >= index+1:
download_video(index,True)
else:
downloading = False
def wait_for_next_video(): def wait_for_next_video():
@ -270,24 +203,22 @@ def wait_for_next_video():
return return
stat = obs.get_scene_item_id("youtube", "notice") stat = obs.get_scene_item_id("youtube", "notice")
print(stat.scene_item_id) print(stat.scene_item_id)
#if not os.path.isfile(f"{vid_dir}/{vidcounter+1}.mp4"):
print("Attempting to enable") print("Attempting to enable")
obs.set_scene_item_enabled("youtube", stat.scene_item_id, True) obs.set_scene_item_enabled("youtube", stat.scene_item_id, True)
while not os.path.isfile(f"{vid_dir}/{vidcounter+1}.mp4"): while not os.path.isfile(f"{vid_dir}/{vidcounter+1}.mp4"):
counter = counter + 1 counter = counter + 1
sleep(0.5) sleep(0.5)
if counter == 120 and len(os.listdir(full_dl_dir)) == 0: if counter == 20 and len(os.listdir(full_dl_dir)) == 0:
print("failsafe activated") print("failsafe activated")
download_video(0,True) download_video(0)
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
obs.set_scene_item_enabled("youtube", stat.scene_item_id, False) obs.set_scene_item_enabled("youtube", stat.scene_item_id, False)
return return
def cold_run(): def cold_run():
scene = obs.get_current_program_scene() download_video(0)
if scene.scene_name != "waiting": os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter}.mp4")
return
download_video(0,renameoffset=0)
if not os.path.isfile(f"{vid_dir}/{vidcounter}.mp4"):
return
obs.set_current_program_scene("youtube") obs.set_current_program_scene("youtube")
nowplayingid = obs.get_scene_item_id("youtube", "nowplaying") nowplayingid = obs.get_scene_item_id("youtube", "nowplaying")
stat = obs.get_scene_item_id("youtube", "notice") stat = obs.get_scene_item_id("youtube", "notice")
@ -296,6 +227,9 @@ def cold_run():
obs.set_input_settings("nowplaying", {'text': f'{vid_details["title"]}\nBy {vid_details["channel"]}'}, True) obs.set_input_settings("nowplaying", {'text': f'{vid_details["title"]}\nBy {vid_details["channel"]}'}, True)
obs.set_scene_item_enabled("youtube", nowplayingid.scene_item_id, True) obs.set_scene_item_enabled("youtube", nowplayingid.scene_item_id, True)
obs.trigger_media_input_action("player", "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_RESTART") obs.trigger_media_input_action("player", "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_RESTART")
if len(queue) > 1:
download_video(1)
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
def on_media_input_playback_ended(data): def on_media_input_playback_ended(data):
global vidcounter global vidcounter
@ -312,6 +246,7 @@ def on_media_input_playback_ended(data):
print("alternative download triggered") 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")
else: else:
obs.set_current_program_scene("waiting") obs.set_current_program_scene("waiting")
os.remove(f"{vid_dir}/{vidcounter}.mp4") os.remove(f"{vid_dir}/{vidcounter}.mp4")
@ -319,8 +254,10 @@ def on_media_input_playback_ended(data):
return return
wait_for_next_video() wait_for_next_video()
print(queue) print(queue)
#obs.set_current_program_scene("youtube2")
os.remove(f"{vid_dir}/{vidcounter}.mp4") os.remove(f"{vid_dir}/{vidcounter}.mp4")
vidcounter = vidcounter + 1 vidcounter = vidcounter + 1
#os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter}.mp4")
print("changing obs settigs") print("changing obs settigs")
scene = obs.get_current_program_scene() scene = obs.get_current_program_scene()
if scene.scene_name != "youtube": if scene.scene_name != "youtube":
@ -335,9 +272,11 @@ def on_media_input_playback_ended(data):
obs.set_scene_item_enabled("youtube", nowplayingid.scene_item_id, True) #same as above obs.set_scene_item_enabled("youtube", nowplayingid.scene_item_id, True) #same as above
if len(queue) > 1: if len(queue) > 1:
download_video(1) download_video(1)
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
elif sqllen() >= 1 and len(queue) == 1: elif sqllen() >= 1 and len(queue) == 1:
propagate_queue(1) propagate_queue(1)
download_video(1) download_video(1)
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
@bot.slash_command( @bot.slash_command(
name="stats", name="stats",
@ -384,14 +323,14 @@ async def play(inter: disnake.AppCmdInter, link: str):
scene = obs.get_current_program_scene() 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: 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()
propagate_queue(1) #queue.clear() #safety
propagate_queue(2)
await loop.run_in_executor(None, cold_run) await loop.run_in_executor(None, cold_run)
return
elif (not os.path.isfile(f"{vid_dir}/{vidcounter+1}.mp4")) and sqllen() >= 1 and len(queue) == 1: elif (not os.path.isfile(f"{vid_dir}/{vidcounter+1}.mp4")) and sqllen() >= 1 and len(queue) == 1:
loop = asyncio.get_running_loop() loop = asyncio.get_running_loop()
propagate_queue(2) propagate_queue(2)
await loop.run_in_executor(None, download_video, 1) await loop.run_in_executor(None, download_video, 1)
return 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")
@ -399,8 +338,7 @@ async def play(inter: disnake.AppCmdInter, link: str):
@bot.slash_command( @bot.slash_command(
name="shuffle", name="shuffle",
description="toggles shuffle on or off", description="toggles shuffle on or off, the queue cannot be unshuffled once it is shuffled",
default_member_permissions=disnake.Permissions(8192),
) )
async def shuffleplay(inter: disnake.AppCmdInter, toggle: str = commands.Param(choices=["on", "off"])): async def shuffleplay(inter: disnake.AppCmdInter, toggle: str = commands.Param(choices=["on", "off"])):
if os.getenv("LOCK_SHUFFLE","FALSE") == "TRUE": if os.getenv("LOCK_SHUFFLE","FALSE") == "TRUE":
@ -513,7 +451,6 @@ async def button_listener(inter: disnake.MessageInteraction):
@bot.slash_command( @bot.slash_command(
name="toggleplayback", name="toggleplayback",
description="play or pause the video", description="play or pause the video",
default_member_permissions=disnake.Permissions(8192),
) )
async def toggleplayback(inter: disnake.AppCmdInter): async def toggleplayback(inter: disnake.AppCmdInter):
stat = obs.get_media_input_status("player") stat = obs.get_media_input_status("player")
@ -547,6 +484,7 @@ async def skip(inter: disnake.AppCmdInter):
return return
await loop.run_in_executor(None, wait_for_next_video) await loop.run_in_executor(None, wait_for_next_video)
print("stopping video") print("stopping video")
#obs.trigger_media_input_action("player", "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_PAUSE")
os.remove(f"{vid_dir}/{vidcounter}.mp4") os.remove(f"{vid_dir}/{vidcounter}.mp4")
vidcounter = vidcounter + 1 vidcounter = vidcounter + 1
nowplayingid = obs.get_scene_item_id("youtube", "nowplaying") nowplayingid = obs.get_scene_item_id("youtube", "nowplaying")
@ -557,6 +495,7 @@ async def skip(inter: disnake.AppCmdInter):
await inter.edit_original_response("skipped as sufficient votes were reached") await inter.edit_original_response("skipped as sufficient votes were reached")
if len(queue) > 1: if len(queue) > 1:
await loop.run_in_executor(None, download_video, 1) await loop.run_in_executor(None, download_video, 1)
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
@bot.slash_command( @bot.slash_command(
@ -613,6 +552,8 @@ async def voteskip(inter: disnake.AppCmdInter):
await inter.edit_original_response("skipped as sufficient votes were reached") await inter.edit_original_response("skipped as sufficient votes were reached")
if len(queue) > 1: if len(queue) > 1:
await loop.run_in_executor(None, download_video, 1) await loop.run_in_executor(None, download_video, 1)
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
else:
await inter.edit_original_response(f"**{inter.user.display_name}** has voted to skip the video, {len(skip_list)}/{math.floor(len(vc)/2)}") await inter.edit_original_response(f"**{inter.user.display_name}** has voted to skip the video, {len(skip_list)}/{math.floor(len(vc)/2)}")
@ -643,6 +584,7 @@ async def videotimer():
return return
await loop.run_in_executor(None, wait_for_next_video) await loop.run_in_executor(None, wait_for_next_video)
print("stopping video") print("stopping video")
#obs.trigger_media_input_action("player", "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_PAUSE")
os.remove(f"{vid_dir}/{vidcounter}.mp4") os.remove(f"{vid_dir}/{vidcounter}.mp4")
vidcounter = vidcounter + 1 vidcounter = vidcounter + 1
nowplayingid = obs.get_scene_item_id("youtube", "nowplaying") nowplayingid = obs.get_scene_item_id("youtube", "nowplaying")
@ -652,6 +594,7 @@ async def videotimer():
obs.set_scene_item_enabled("youtube", nowplayingid.scene_item_id, True) obs.set_scene_item_enabled("youtube", nowplayingid.scene_item_id, True)
if len(queue) > 1: if len(queue) > 1:
await loop.run_in_executor(None, download_video, 1) await loop.run_in_executor(None, download_video, 1)
os.rename(f"{vid_dir}/999zznext.mp4", f"{vid_dir}/{vidcounter+1}.mp4")
except Exception: except Exception:
pass pass
return return
@ -673,7 +616,7 @@ 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 sqllen() >= 1 and not downloading: #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) propagate_queue(2)
await loop.run_in_executor(None, download_video, 0) await loop.run_in_executor(None, download_video, 0)
@ -693,12 +636,8 @@ async def titlehandler():
bot.run(os.getenv("TOKEN")) bot.run(os.getenv("TOKEN"))
print("cleaning up") print("cleaning up tempdir")
temp_dir.cleanup() temp_dir.cleanup()
download_dir.cleanup() download_dir.cleanup()
cur.close()
con.commit()
con.close() con.close()
obs.set_current_program_scene("nosignal") obs.set_current_program_scene("nosignal")
obs.disconnect()
obse.disconnect()