Use cookies

This commit is contained in:
ekzyis 2021-09-25 20:02:51 +02:00
parent 9cce0f9f91
commit 9e75fd5cbe
2 changed files with 7 additions and 5 deletions

View File

@ -1 +1,2 @@
BOT_TOKEN=
DISCORD_BOT_TOKEN=
YOUTUBE_COOKIES=

View File

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