From a864af61b348d326fb3105d32b21936de488e2e5 Mon Sep 17 00:00:00 2001 From: Trygve Date: Sun, 31 Jul 2022 22:59:30 +0200 Subject: [PATCH] Reorganizing --- main.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index 7ede2c5..00607d8 100644 --- a/main.py +++ b/main.py @@ -15,24 +15,12 @@ class MyLogger(object): def error(self, msg): print(msg) - -creds = botlib.Creds(config['url'], config['username'], config['password']) -bot = botlib.Bot(creds) - def progress_hook(d): if d['status'] == 'started': print('Started downloading') elif d['status'] == 'finished': print('Done downloading') -ydl_opts = { - 'format': config['yt_dlp_format'], - 'outtmpl': config['download_dir'] + '/%(title)s.%(ext)s', - 'restrictfilenames': True, - 'logger': MyLogger(), - 'progress_hooks': [progress_hook], -} - def get_yt_vid_id(word): if search('www.youtube.com/watch', word): return word @@ -58,4 +46,14 @@ async def youtube(room, message): except Exception as e: await bot.api.send_text_message(room.room_id, str(e)) +creds = botlib.Creds(config['url'], config['username'], config['password']) +bot = botlib.Bot(creds) +ydl_opts = { + 'format': config['yt_dlp_format'], + 'outtmpl': config['download_dir'] + '/%(title)s.%(ext)s', + 'restrictfilenames': True, + 'logger': MyLogger(), + 'progress_hooks': [progress_hook], +} + bot.run()