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()