From 9e75fd5cbef87ffaa07ff76d17ea086a17a9bd59 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sat, 25 Sep 2021 20:02:51 +0200 Subject: [PATCH 1/2] Use cookies --- .env.template | 3 ++- src/bot.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) 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/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) From 737173dcd6bf4eca39a64b243415ab8f89750655 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sat, 25 Sep 2021 20:09:16 +0200 Subject: [PATCH 2/2] Add cookies.txt --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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