Coroutine fix

This commit is contained in:
2024-04-03 13:44:44 +02:00
committed by migatu
parent d8f5bd1805
commit 39ecb82395
+5 -4
View File
@@ -663,7 +663,7 @@ async def get_file(ctx, source, link):
url_dict["songs"] = file_list
url_data["urls"].append(url_dict.copy())
file_name_f = youtube_download.default_filename
youtube_download.download_songs(
coro = asyncio.to_thread(youtube_download.download_songs,
songs=url_data,
output_dir=MUSIC_FOLDER,
format_str="bestaudio/best",
@@ -676,6 +676,7 @@ async def get_file(ctx, source, link):
multi_core=0,
proxy="",
)
_ = await coro
dir_path = (url_dict["save_path"].resolve()).as_posix()
if platform == "win32":
dir_path = dir_path.replace("/", "\\")
@@ -728,7 +729,8 @@ async def get_file(ctx, source, link):
ydl_opts["postprocessors"].append(mp3_postprocess_opts.copy())
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
try:
ydl.download([query])
coro = asyncio.to_thread(ydl.download, [query])
_ = await coro
except Exception as exce: # pylint: disable=broad-exception-caught
logger.error(exce)
logger.info(
@@ -1300,8 +1302,7 @@ async def zagraj_mi_kawalek(ctx):
async with ctx.typing():
search_time_glob = datetime.now()
logger.info("Zaczynam szukać timestamp %s", datetime.now())
coro = asyncio.to_thread(wyszukaj,ctx=ctx)
file = await coro
file = await wyszukaj(ctx=ctx)
logger.info(
"Koniec szukania(timestamp %s zajęło %s",
datetime.now(),