From 366adc2423c85b32a742eb5b878f20a0d025d393 Mon Sep 17 00:00:00 2001 From: a <a@trwnh.com> Date: Wed, 13 Nov 2024 23:26:47 +0000 Subject: [PATCH] Change to using cookies bc OAuth is getting patched out --- README.md | 36 ++++++++++++++++++++++++------------ cogs/music.py | 4 ++-- umi@.service | 13 +++++++++++++ 3 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 umi@.service diff --git a/README.md b/README.md index a5c4499..2ceb8e8 100644 --- a/README.md +++ b/README.md @@ -28,27 +28,39 @@ Copy `.env.example` to `.env`: ## Setup -### ...with PDM +### with systemd ```sh -pdm install --prod -pdm run python app.py -``` +mkdir -p /srv/discord +cd /srv/discord -### ...with requirements.txt and virtualenv +sudo useradd --system -s /srv/discord discord +sudo chown -R discord:discord /srv/discord -```sh -virtualenv .venv -source .venv/bin/activate -pip install -r requirements.txt -python app.py +sudo -Hu discord git clone https://git.trwnh.com/a/umi.git + +python -m venv .venv +.venv/bin/pip install -r umi/requirements.txt + +sudo cp umi/umi@.service /etc/systemd/system/umi@.service +sudo systemctl daemon-reload +sudo systemctl start umi@umi ``` ### ...with Docker Compose ```sh -docker compose build -docker compose up -d +mkdir -p /srv/discord +cd /srv/discord + +sudo useradd --system -s /srv/discord discord +sudo chown -R discord:discord /srv/discord + +sudo -Hu discord git clone https://git.trwnh.com/a/umi.git + +cd umi +sudo docker compose build +sudo docker compose up -d ``` ## Log into YouTube diff --git a/cogs/music.py b/cogs/music.py index fa1430e..2cf7672 100644 --- a/cogs/music.py +++ b/cogs/music.py @@ -923,8 +923,8 @@ ytdl_format_options = { "default_search": "auto", # "source_address": "0.0.0.0", # Bind to ipv4 since ipv6 addresses cause issues "extract_flat": True, # massive speedup for fetching metadata, at the cost of no upload date - #"cookiefile": "cookies.txt", + "cookiefile": "config/cookies.txt", "cachedir": "cache", - "usenetrc": True + #"usenetrc": True, } ytdl = youtube_dl.YoutubeDL(ytdl_format_options) \ No newline at end of file diff --git a/umi@.service b/umi@.service new file mode 100644 index 0000000..9bbc1b2 --- /dev/null +++ b/umi@.service @@ -0,0 +1,13 @@ +[Unit] +Description=Discord bot for logging VC joins and playing music +After=network.target + +[Service] +Restart=on-failure +User=discord +WorkingDirectory=/srv/discord/%I +EnvironmentFile=/srv/discord/%I/.env +ExecStart=/srv/discord/.venv/bin/python -u app.py + +[Install] +WantedBy=multi-user.target