mirror of
https://github.com/tgbot-collection/ytdlbot.git
synced 2025-02-24 23:34:44 +08:00
use async everywhere
This commit is contained in:
parent
508a6bfd5f
commit
d245780de5
1 changed files with 2 additions and 2 deletions
4
bot.py
4
bot.py
|
@ -49,7 +49,7 @@ def progress_hook(d: dict, chat_id, message):
|
||||||
threading.Thread(target=go, args=(chat_id, message, msg)).start()
|
threading.Thread(target=go, args=(chat_id, message, msg)).start()
|
||||||
|
|
||||||
|
|
||||||
def ytdl_download(url, tempdir, chat_id, message) -> dict:
|
async def ytdl_download(url, tempdir, chat_id, message) -> dict:
|
||||||
response = dict(status=None, error=None, filepath=None)
|
response = dict(status=None, error=None, filepath=None)
|
||||||
logging.info("Downloading for %s", url)
|
logging.info("Downloading for %s", url)
|
||||||
output = os.path.join(tempdir, '%(title)s.%(ext)s')
|
output = os.path.join(tempdir, '%(title)s.%(ext)s')
|
||||||
|
@ -103,7 +103,7 @@ async def echo_all(event):
|
||||||
temp_dir = tempfile.TemporaryDirectory()
|
temp_dir = tempfile.TemporaryDirectory()
|
||||||
|
|
||||||
async with bot.action(chat_id, 'video'):
|
async with bot.action(chat_id, 'video'):
|
||||||
result = ytdl_download(url, temp_dir.name, chat_id, message)
|
result = await ytdl_download(url, temp_dir.name, chat_id, message)
|
||||||
|
|
||||||
if result["status"]:
|
if result["status"]:
|
||||||
async with bot.action(chat_id, 'document'):
|
async with bot.action(chat_id, 'document'):
|
||||||
|
|
Loading…
Reference in a new issue