implement spotizerr-auth

This commit is contained in:
Xoconoch
2025-06-05 14:55:43 -06:00
parent 95e30fd041
commit 1656c598b6
3 changed files with 9 additions and 113 deletions

111
README.md
View File

@@ -61,114 +61,9 @@ Access at: `http://localhost:7171`
## Configuration
### Initial Setup
1. Access settings via the gear icon
2. Switch between service tabs (Spotify/Deezer)
3. Enter credentials using the form
4. Configure active accounts in settings
### Spotify Setup
_Note: If you want Spotify-only mode, just keep "Download fallback" setting disabled and don't bother adding Deezer credentials. Deezer-only mode is not, and will not be supported since there already is a much better tool for that called "Deemix"_
### Spotify Credentials Setup
First create a Spotify credentials file using the 3rd-party `librespot-auth` tool, this step has to be done in a PC/Laptop that has the Spotify desktop app installed.
---
#### For Linux (using Docker)
1. Clone the `librespot-auth` repository:
```shell
git clone --depth 1 https://github.com/dspearson/librespot-auth.git
```
2. Build the repository using the Rust Docker image:
```shell
docker run --rm -v "$(pwd)/librespot-auth":/app -w /app rust:latest cargo build --release
```
3. Run the built binary:
```shell
./librespot-auth/target/release/librespot-auth --name "mySpotifyAccount1" --class=computer
```
---
#### For Windows (using Docker)
1. Clone the `librespot-auth` repository:
```shell
git clone --depth 1 https://github.com/dspearson/librespot-auth.git
```
2. Build the repository using a windows-targeted Rust Docker image ([why a different image?](https://github.com/jscharnitzke/rust-build-windows)):
```shell
docker run --rm -v "${pwd}/librespot-auth:/app" -w "/app" jscharnitzke/rust-build-windows --release
```
3. Run the built binary:
```shell
.\librespot-auth\target\x86_64-pc-windows-gnu\release\librespot-auth.exe --name "mySpotifyAccount1" --class=computer
```
---
#### For Apple Silicon (macOS)
1. Clone the `librespot-auth` repository:
```shell
git clone --depth 1 https://github.com/dspearson/librespot-auth.git
```
2. Install Rust using Homebrew:
```shell
brew install rustup
brew install rust
```
3. Build `librespot-auth` for Apple Silicon:
```shell
cd librespot-auth
cargo build --target=aarch64-apple-darwin --release
```
4. Run the built binary:
```shell
./target/aarch64-apple-darwin/release/librespot-auth --name "mySpotifyAccount1" --class=computer
```
---
- Now open the Spotify app
- Click on the "Connect to a device" icon
- Under the "Select Another Device" section, click "mySpotifyAccount1"
- This utility will create a `credentials.json` file
This file has the following format:
```
{"username": "long text" "auth_type": 1 "auth_data": "even longer text"}
```
The important ones are the "username" and "auth_data" parameters, these match the "username" and "credentials" sections respectively when adding/editing spotify credentials in Spotizerr.
In the terminal, you can directly print these parameters using jq:
```
jq -r '.username, .auth_data' credentials.json
```
### Spotify Developer Setup
In order for searching to work, you need to set up your own Spotify Developer application:
1. Visit the [Spotify Developer Dashboard](https://developer.spotify.com/dashboard/)
2. Log in with your Spotify account
3. Click "Create app"
4. Fill in:
- App name (e.g., "My Spotizerr App")
- App description
- Redirect URI: `http://127.0.0.1:7171/callback` (or your custom domain if exposed)
- Check the Developer Terms agreement box
5. Click "Create"
6. On your app page, note your "Client ID"
7. Click "Show client secret" to reveal your "Client Secret"
8. Add these credentials in Spotizerr's settings page under the Spotify service section
Spotify is VERY petty, so, in order to simplify the process, another tool was created to perform this part of the setup; see [spotizerr-auth](https://github.com/Xoconoch/spotizerr-auth)
### Deezer ARL Setup
@@ -266,4 +161,4 @@ Copy that value and paste it into the correspondant setting in Spotizerr
# Acknowledgements
- This project is based on the amazing [deezspot library](https://github.com/jakiepari/deezspot), although their creators are in no way related with Spotizerr, they still deserve credit
- This project was inspired by the amazing [deezspot library](https://github.com/jakiepari/deezspot), although their creators are in no way related with Spotizerr, they still deserve credit.

View File

@@ -5,6 +5,7 @@ from routes.utils.credentials import (
create_credential,
delete_credential,
edit_credential,
init_credentials_db,
# Import new utility functions for global Spotify API creds
_get_global_spotify_api_creds,
save_global_spotify_api_creds
@@ -15,6 +16,9 @@ import logging
logger = logging.getLogger(__name__)
credentials_bp = Blueprint('credentials', __name__)
# Initialize the database and tables when the blueprint is loaded
init_credentials_db()
@credentials_bp.route('/spotify_api_config', methods=['GET', 'PUT'])
def handle_spotify_api_config():
"""Handles GET and PUT requests for the global Spotify API client_id and client_secret."""

View File

@@ -80,7 +80,6 @@ def init_credentials_db():
try:
with _get_db_connection() as conn:
cursor = conn.cursor()
cursor.row_factory = sqlite3.Row # Apply row_factory here as well for consistency
# Spotify Table
cursor.execute("""
CREATE TABLE IF NOT EXISTS spotify (
@@ -90,8 +89,7 @@ def init_credentials_db():
updated_at REAL
)
""")
if _ensure_table_schema(cursor, "spotify", EXPECTED_SPOTIFY_TABLE_COLUMNS):
conn.commit()
_ensure_table_schema(cursor, "spotify", EXPECTED_SPOTIFY_TABLE_COLUMNS)
# Deezer Table
cursor.execute("""
@@ -103,8 +101,7 @@ def init_credentials_db():
updated_at REAL
)
""")
if _ensure_table_schema(cursor, "deezer", EXPECTED_DEEZER_TABLE_COLUMNS):
conn.commit()
_ensure_table_schema(cursor, "deezer", EXPECTED_DEEZER_TABLE_COLUMNS)
# Ensure global search.json exists, create if not
if not GLOBAL_SEARCH_JSON_PATH.exists():