From 8f9feebaf73cc88a176d2488f1538602ba6a99ce Mon Sep 17 00:00:00 2001 From: Trygve Date: Mon, 1 Aug 2022 00:01:37 +0200 Subject: [PATCH] More reordering --- main.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 00607d8..01ff287 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ import yt_dlp from config import config -class MyLogger(object): +class Logger(object): def debug(self, msg): pass @@ -29,6 +29,16 @@ def get_yt_vid_id(word): else: return False +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': Logger(), + 'progress_hooks': [progress_hook], +} + @bot.listener.on_message_event async def youtube(room, message): match = botlib.MessageMatch(room, message, bot) @@ -46,14 +56,4 @@ 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()