From bb44b439742e5a2dcae8b7ea08b88d7431e9c44c Mon Sep 17 00:00:00 2001 From: Raiper34 Date: Sat, 7 Feb 2026 14:14:48 +0000 Subject: [PATCH] feat(files): add possibility to set the audio quality of downloaded files it is possible now to se audio quality of files using environment variables (QUALITY) close #39 --- README.md | 33 ++++++++++++----------- src/backend/.env.default | 1 + src/backend/src/shared/youtube.service.ts | 1 + 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 61c7aa2..e91a094 100644 --- a/README.md +++ b/README.md @@ -79,13 +79,13 @@ services: Spooty can be also build from source files on your own. #### Requirements -- Node v18.19.1 (it is recommended to use `nvm` node version manager to install proper version of node) +- Node v20.20.0 (it is recommended to use `nvm` node version manager to install proper version of node) - Redis in memory cache - Ffmpeg - Python3 #### Process -- install Node v18.19.1 using `nvm install` and use that node version `nvm use` +- install Node v20.20.0 using `nvm install` and use that node version `nvm use` - from project root install all dependencies using `npm install` - copy `.env.default` as `.env` in `src/backend` folder and modify desired environment properties (see [environment variables](#environment-variables)) - add your Spotify application credentials to the `.env` file: @@ -101,20 +101,21 @@ 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 (currently fully supported only `mp3` but you can try whatever you want from [ffmpeg](https://ffmpeg.org/ffmpeg-formats.html#Muxers)) | - 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 | | Allows you to pass your YouTube cookies to bypass some download restrictions. See [below](#how-to-get-your-youtube-cookies) for instructions. | ### How to get your YouTube cookies (using browser dev tools): 1. Go to https://www.youtube.com and log in if needed. diff --git a/src/backend/.env.default b/src/backend/.env.default index f2adc5a..2bbe253 100644 --- a/src/backend/.env.default +++ b/src/backend/.env.default @@ -2,6 +2,7 @@ DB_PATH=./config/db.sqlite FE_PATH=../frontend/browser DOWNLOADS_PATH=./downloads FORMAT=mp3 +QUALITY= PORT=3000 REDIS_PORT=6379 REDIS_HOST=localhost diff --git a/src/backend/src/shared/youtube.service.ts b/src/backend/src/shared/youtube.service.ts index 59fabac..0320b5b 100644 --- a/src/backend/src/shared/youtube.service.ts +++ b/src/backend/src/shared/youtube.service.ts @@ -42,6 +42,7 @@ export class YoutubeService { cookiesFromBrowser: this.configService.get('YT_COOKIES'), headers: HEADERS, jsRuntime: 'node', + audioQuality: this.configService.get('QUALITY'), }, ); this.logger.debug(