diff --git a/.env.template b/.env.template index 978ac4c..7ab5466 100644 --- a/.env.template +++ b/.env.template @@ -1 +1,2 @@ -BOT_TOKEN= \ No newline at end of file +DISCORD_BOT_TOKEN= +YOUTUBE_COOKIES= \ No newline at end of file diff --git a/.gitignore b/.gitignore index f106780..dbe309b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ venv __pycache__ .env .coverage +*cookies.txt \ No newline at end of file diff --git a/src/bot.py b/src/bot.py index c5c4f98..79dc9c0 100644 --- a/src/bot.py +++ b/src/bot.py @@ -20,7 +20,8 @@ class Music(commands.Cog): self._bot = bot self._queue = asyncio.Queue() self._queue_lock = asyncio.Lock() - self._ytdl_format_options = { + self._ytdl_params = { + 'cookiefile': os.environ.get('YOUTUBE_COOKIES'), 'format': 'bestaudio/best', 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s', 'restrictfilenames': True, @@ -36,7 +37,7 @@ class Music(commands.Cog): self._ffmpeg_options = { 'options': '-vn' } - self._ytdl = youtube_dl.YoutubeDL(self._ytdl_format_options) + self._ytdl = youtube_dl.YoutubeDL(self._ytdl_params) # pylint: disable=no-member self._handle_playback.start() @@ -99,9 +100,9 @@ if __name__ == "__main__": bot.add_cog(Music(bot)) bot.add_cog(ErrorHandler(bot)) - token = os.environ.get("BOT_TOKEN", None) + token = os.environ.get("DISCORD_BOT_TOKEN", None) if not token: - print("No token found in BOT_TOKEN") + print("Discord bot token not found") sys.exit(1) bot.run(token)