feat: add YT_COOKIES_FILE support for Netscape cookies.txt
Previously, the only way to pass YouTube cookies was via the YT_COOKIES env var, which was incorrectly documented as a raw cookie string (name=value; ...) but internally mapped to yt-dlp's --cookies-from-browser, which expects a browser name (e.g. chrome, firefox). This made the feature non-functional as documented and unusable in Docker environments where no browser is present. This change introduces a second option, YT_COOKIES_FILE, which accepts a path to a Netscape-format cookies.txt file and maps to yt-dlp's --cookies flag. This is the recommended approach for Docker deployments, where users can export cookies via a browser extension and bind mount the file into the container. The file is only passed to yt-dlp if it actually exists on disk, so the default path (./config/cookies.txt) does not cause errors when no file is provided. YT_COOKIES retains priority over YT_COOKIES_FILE if both are set. README is updated to clarify the correct usage of both options, fix the misleading cookie string instructions, add a dedicated YouTube cookies section to the table of contents, and include the cookies.txt bind mount in the Docker usage examples. Resolves #40, resolves #48
This commit is contained in:
@@ -26,6 +26,7 @@ The project is based on NestJS and Angular.
|
||||
- [Process](#requirements)
|
||||
- [Requirements](#process)
|
||||
- [Environment variables](#environment-variables)
|
||||
- [YouTube cookies](#youtube-cookies)
|
||||
- [⚖️ License](#-license)
|
||||
|
||||
## 🚀 Installation
|
||||
@@ -52,6 +53,7 @@ For detailed configuration, see available [environment variables](#environment-v
|
||||
```shell
|
||||
docker run -d -p 3000:3000 \
|
||||
-v /path/to/downloads:/spooty/backend/downloads \
|
||||
-v /path/to/cookies.txt:/spooty/config/cookies.txt \
|
||||
-e SPOTIFY_CLIENT_ID=your_client_id \
|
||||
-e SPOTIFY_CLIENT_SECRET=your_client_secret \
|
||||
raiper34/spooty:latest
|
||||
@@ -68,6 +70,7 @@ services:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- /path/to/downloads:/spooty/backend/downloads
|
||||
- /path/to/cookies.txt:/spooty/config/cookies.txt
|
||||
environment:
|
||||
- SPOTIFY_CLIENT_ID=your_client_id
|
||||
- SPOTIFY_CLIENT_SECRET=your_client_secret
|
||||
@@ -101,30 +104,54 @@ Spooty can be also build from source files on your own.
|
||||
|
||||
Some behaviour and settings of Spooty can be configured using environment variables and `.env` file.
|
||||
|
||||
Name | Default | Description |
|
||||
----------------------|---------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
DB_PATH | `./config/db.sqlite` (relative to backend) | Path where Spooty database will be stored |
|
||||
FE_PATH | `../frontend/browser` (relative to backend) | Path to frontend part of application |
|
||||
DOWNLOADS_PATH | `./downloads` (relative to backend) | Path where downaloded files will be stored |
|
||||
FORMAT | `mp3` | Format of downloaded files ('aac', 'flac', 'mp3', 'm4a', 'opus', 'vorbis', 'wav', 'alac') |
|
||||
QUALITY | undefined | Audio quality (0-9 VBR or specific bitrate) of downloaded files |
|
||||
PORT | 3000 | Port of Spooty server |
|
||||
REDIS_PORT | 6379 | Port of Redis server |
|
||||
REDIS_HOST | localhost | Host of Redis server |
|
||||
RUN_REDIS | false | Whenever Redis server should be started from backend (recommended for Docker environment) |
|
||||
SPOTIFY_CLIENT_ID | your_client_id | Client ID of your Spotify application (required) |
|
||||
SPOTIFY_CLIENT_SECRET| your_client_secret | Client Secret of your Spotify application (required) |
|
||||
YT_DOWNLOADS_PER_MINUTE | 3 | Set the maximum number of YouTube downloads started per minute |
|
||||
YT_COOKIES | | Allows you to pass your YouTube cookies to bypass some download restrictions. See [below](#how-to-get-your-youtube-cookies) for instructions. |
|
||||
Name | Default | Description |
|
||||
-------------------------|---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
DB_PATH | `./config/db.sqlite` (relative to backend) | Path where Spooty database will be stored |
|
||||
FE_PATH | `../frontend/browser` (relative to backend) | Path to frontend part of application |
|
||||
DOWNLOADS_PATH | `./downloads` (relative to backend) | Path where downaloded files will be stored |
|
||||
FORMAT | `mp3` | Format of downloaded files ('aac', 'flac', 'mp3', 'm4a', 'opus', 'vorbis', 'wav', 'alac') |
|
||||
QUALITY | undefined | Audio quality (0-9 VBR or specific bitrate) of downloaded files |
|
||||
PORT | 3000 | Port of Spooty server |
|
||||
REDIS_PORT | 6379 | Port of Redis server |
|
||||
REDIS_HOST | localhost | Host of Redis server |
|
||||
RUN_REDIS | false | Whenever Redis server should be started from backend (recommended for Docker environment) |
|
||||
SPOTIFY_CLIENT_ID | your_client_id | Client ID of your Spotify application (required) |
|
||||
SPOTIFY_CLIENT_SECRET | your_client_secret | Client Secret of your Spotify application (required) |
|
||||
YT_DOWNLOADS_PER_MINUTE | 3 | Set the maximum number of YouTube downloads started per minute |
|
||||
YT_COOKIES | | Browser name to automatically extract YouTube cookies from (e.g. `chrome`, `firefox`). Only works when running Spooty natively (not in Docker). See [below](#yt_cookies---browser-based-cookies-non-docker). |
|
||||
YT_COOKIES_FILE | `./config/cookies.txt` | Path to a Netscape-format `cookies.txt` file. Recommended for Docker deployments. See [below](#yt_cookies_file---cookies-file-recommended-for-docker). |
|
||||
|
||||
### How to get your YouTube cookies (using browser dev tools):
|
||||
1. Go to https://www.youtube.com and log in if needed.
|
||||
2. Open the browser developer tools (F12 or right click > Inspect).
|
||||
3. Go to the "Application" tab (in Chrome) or "Storage" (in Firefox).
|
||||
4. In the left menu, find "Cookies" and select https://www.youtube.com.
|
||||
5. Copy all the cookies (name=value) and join them with a semicolon and a space, like:
|
||||
VISITOR_INFO1_LIVE=xxxx; YSC=xxxx; SID=xxxx; ...
|
||||
6. Paste this string into the YT_COOKIES environment variable (in your .env or Docker config).
|
||||
### YouTube cookies
|
||||
|
||||
YouTube may block or throttle downloads without authentication cookies. Spooty supports two ways to provide them — use the one that fits your setup.
|
||||
|
||||
#### `YT_COOKIES` — browser-based cookies (non-Docker)
|
||||
|
||||
Set `YT_COOKIES` to the name of your browser and yt-dlp will automatically read cookies directly from it.
|
||||
Supported values: `chrome`, `firefox`, `edge`, `safari`, `brave`, `opera`, `chromium`.
|
||||
|
||||
```
|
||||
YT_COOKIES=chrome
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> This only works when Spooty runs on the same machine as your browser (i.e. not in Docker, where no browser is present).
|
||||
|
||||
#### `YT_COOKIES_FILE` — cookies file (recommended for Docker)
|
||||
|
||||
Export your YouTube cookies as a Netscape `cookies.txt` file and provide its path. This is the recommended approach for Docker deployments.
|
||||
|
||||
**How to get your `cookies.txt` file:**
|
||||
1. Install a browser extension that exports cookies in Netscape format, e.g. [Get cookies.txt LOCALLY](https://chrome.google.com/webstore/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc) for Chrome or [cookies.txt](https://addons.mozilla.org/en-US/firefox/addon/cookies-txt/) for Firefox.
|
||||
2. Go to https://www.youtube.com and log in.
|
||||
3. Use the extension to export cookies for `youtube.com` and save the file as `cookies.txt`.
|
||||
|
||||
**Docker usage:**
|
||||
|
||||
Bind mount the `cookies.txt` file into the container and set `YT_COOKIES_FILE` to its path inside the container. See the [Environment variables](#environment-variables) section for details.
|
||||
|
||||
> [!NOTE]
|
||||
> `YT_COOKIES` takes priority over `YT_COOKIES_FILE` if both are set.
|
||||
|
||||
# ⚖️ License
|
||||
[MIT](https://choosealicense.com/licenses/mit/)
|
||||
|
||||
Reference in New Issue
Block a user