Get Spotify tracks in true FLAC from Tidal, Qobuz & Amazon Music — no account required.
Project description
SpotiFLAC Python Module
Integrate SpotiFLAC directly into your Python projects. Perfect for building custom Telegram bots, automation tools, bulk downloaders, jellyfin downloader musics or web interfaces.
Looking for a standalone app?
SpotiFLAC (Desktop)
Download music in true lossless FLAC from Tidal, Qobuz & Amazon Music for Windows, macOS & Linux
SpotiFLAC (Mobile)
SpotiFLAC for Android & iOS — maintained by @zarzet
Installation
pip install SpotiFLAC
Quick Start
Import the module and start downloading immediately:
from SpotiFLAC import SpotiFLAC
# Simple Download
SpotiFLAC(
url="https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT",
output_dir="./downloads"
)
New use:
> spotiflac url ./out --service tidal spoti --use-artist-subfolders
Advanced Configuration
You can customize the download behavior, prioritize specific streaming services, and organize your files automatically into folders.
from SpotiFLAC import SpotiFLAC
SpotiFLAC(
url="https://open.spotify.com/album/41MnTivkwTO3UUJ8DrqEJJ",
output_dir="./MusicLibrary",
services=["qobuz", "amazon", "tidal", "spoti", "youtube"],
filename_format="{year} - {album}/{track}. {title}",
use_artist_subfolders=True,
use_album_subfolders=True,
loop=60 # Retry duration in minutes
)
Qobuz Token (Optional)
Setting a personal Qobuz token improves metadata resolution reliability. The token is used as a last resort fallback — requests are first attempted anonymously, and only if they fail (HTTP 400/401) the token is injected. A free Qobuz account is sufficient.
Important: Use throwaway credentials (random email + password you won't forget). You'll need them again if the token expires and needs to be regenerated.
How to Create a Free Account
Go to qobuz.com and register. No payment method required for the free tier.
How to Extract Your Token
- Log in to play.qobuz.com
- Open DevTools with F12 → go to the Network tab
- Play any track or perform any search to trigger API calls
- Filter requests by typing
api.jsonin the search bar - Click on any request to
www.qobuz.com/api.json/... - In the Request Headers panel, look for: x-user-auth-token: your_token_here
- Copy the value — that is your token
Spotify Token (sp_dc) for Synced Lyrics (Optional)
Spotify requires a session cookie called sp_dc to access its internal synced lyrics API.
How to Extract Your Token
- Open your web browser and go to open.spotify.com
- Log in to your Spotify account.
- Open DevTools (F12 or Ctrl+Shift+I / Cmd+Option+I).
- Navigate to the Application tab (or "Storage" in Firefox).
- On the left sidebar, expand Cookies and select https://open.spotify.com.
- Search for the row named sp_dc.
- Double-click its Value, copy it, and keep it safe. (Do not share this token!)
Musixmatch Token (usertoken) for Rich-Synced Lyrics (Optional)
Musixmatch offers highly accurate word-level synchronized lyrics. To use it, you need a user token from their desktop app.
How to Extrack Your Token
- Download and install the official Musixmatch Desktop App (Windows/Mac).
- Log in to your account.
- Open DevTools inside the app (usually Ctrl+Shift+I on Windows or Cmd+Option+I on Mac).
- Go to Network tab.
- Play a song or view lyrics in the app to generate network traffic.
- Look at the requests being made and inspect their Headers or Payload.
- Find the usertoken parameter and copy its alphanumeric value.
Apple Music Token (MusicKit JS Key) (Optional)
Apple Music lyrics require an official Apple Developer Account.
How to Extract Your Token
- You must be enrolled in the Apple Developer Program (paid).
- Go to the Apple Developer Console.
- Create a MusicKit JS Key.
- Generate the developer token using your Key ID and Team ID.
How to Apply Tokens in SpotiFLAC
Once you have your Spotify or Musixmatch tokens, you can pass them to SpotiFLAC in several ways:
Environment Variable (all platforms)
The recommended approach across all systems:
export QOBUZ_AUTH_TOKEN="YOUR_TOKEN_HERE"
export SPOTIFY_TOKEN="YOUR_SP_DC_COOKIE"
export MUSIXMATCH_TOKEN="YOUR_USERTOKEN"
export APPLE_TOKEN="YOUR_MUSICKIT_TOKEN"
On Windows (Command Prompt):
set QOBUZ_AUTH_TOKEN="YOUR_TOKEN_HERE"
set SPOTIFY_TOKEN="YOUR_SP_DC_COOKIE"
set MUSIXMATCH_TOKEN="YOUR_USERTOKEN"
set APPLE_TOKEN="YOUR_MUSICKIT_TOKEN"
On Windows (PowerShell):
$env:QOBUZ_AUTH_TOKEN="YOUR_TOKEN_HERE"
$env:SPOTIFY_TOKEN="YOUR_SP_DC_COOKIE"
$env:MUSIXMATCH_TOKEN="YOUR_USERTOKEN"
$env:APPLE_TOKEN="YOUR_MUSICKIT_TOKEN"
To make it permanent on Linux/macOS, add the export line to your ~/.bashrc, ~/.zshrc, or equivalent shell config file.
.env file (Environment Variables)
If you prefer using a local configuration file for environment variables (highly recommended for development or Docker), you can create a file named .env in the root folder of your project:
QOBUZ_AUTH_TOKEN=YOUR_QOBUZ_TOKEN
SPOTIFY_TOKEN=YOUR_SP_DC_COOKIE
MUSIXMATCH_TOKEN=YOUR_USERTOKEN
APPLE_TOKEN=YOUR_MUSICKIT_TOKEN
You can load this file before running the script from the terminal:
export $(cat .env | xargs) && python launcher.py "URL" ./downloads --embed-lyrics
Or, if you use Docker Compose, you can easily integrate it:
services:
spotiflac:
env_file:
- .env
Add .env to your .gitignore to avoid accidentally committing your token.
CLI (Terminal)
python launcher.py "URL" ./downloads \
--embed-lyrics \
--spotify-token "YOUR_SP_DC_COOKIE" \
--musixmatch-token "YOUR_MUSIXMATCH_USERTOKEN" \
--apple-token "YOUR_MUSICKIT_TOKEN"
Python
from SpotiFLAC import SpotiFLAC
SpotiFLAC(
url="URL",
output_dir="./downloads",
embed_lyrics=True,
lyrics_spotify_token="YOUR_SP_DC_COOKIE",
lyrics_musixmatch_token="YOUR_MUSIXMATCH_USERTOKEN",
lyrics_apple_token="YOUR_MUSICKIT_TOKEN"
)
config.json
{
"qobuz_token": "IL_TUO_TOKEN_QOBUZ",
"spotify_token": "IL_TUO_COOKIE_SP_DC",
"musixmatch_token": "IL_TUO_USERTOKEN",
"apple_token": "IL_TUO_MUSICKIT_TOKEN",
"embed_lyrics": true
}
CLI program usage
Program can be downloaded for Windows, Linux (x86 and ARM) and MacOS. The downloads are available under the releases.
Program can also be ran by downloading the python files and calling python launcher.py with the arguments.
Windows example usage:
./SpotiFLAC-Windows.exe url
output_dir
[--service tidal qobuz spoti youtube amazon]
[--filename-format "{title} - {artist}"]
[--use-track-numbers] [--use-artist-subfolders]
[--use-album-subfolders]
[--loop minutes]
Linux / Mac example usage:
chmod +x SpotiFLAC-Linux-arm64
./SpotiFLAC-Linux-arm64 url
output_dir
[--service tidal qobuz spoti youtube amazon]
[--filename-format "{title} - {artist}"]
[--use-track-numbers] [--use-artist-subfolders]
[--use-album-subfolders]
[--loop minutes]
API Reference
SpotiFLAC() Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
url |
str |
Required | The Spotify URL (Track, Album, or Playlist) you want to download. |
output_dir |
str |
Required | The destination directory path where the audio files will be saved. |
services |
list |
["tidal", "qobuz", "amazon", "deezer", "youtube"] |
Specifies which services to use and their priority order. |
filename_format |
str |
"{title} - {artist}" |
Format for naming downloaded files. See placeholders below. |
use_track_numbers |
bool |
False |
Prefixes the filename with the track number. |
use_artist_subfolders |
bool |
False |
Automatically organizes downloaded files into subfolders by artist. |
use_album_subfolders |
bool |
False |
Automatically organizes downloaded files into subfolders by album. |
loop |
int |
None |
Duration in minutes to keep retrying failed downloads. |
quality |
str |
"LOSSLESS" |
Download quality (e.g., "LOSSLESS", "HI_RES"). |
embed_lyrics |
bool |
False |
Whether to fetch and embed synchronized lyrics (LRC) into the audio file. |
lyrics_providers |
list |
["spotify", "musixmatch", "apple", "amazon", "lrclib"] |
Priority order of lyrics providers to attempt. |
lyrics_spotify_token |
str |
"" |
Spotify sp_dc cookie required for Spotify lyrics. |
lyrics_musixmatch_token |
str |
"" |
Musixmatch usertoken required for Musixmatch lyrics. |
lyrics_apple_token |
str |
"" |
Apple MusicKit developer token required for Apple lyrics. |
enrich_metadata |
bool |
False |
Enables multi-provider metadata enrichment (High-res covers, BPM, Labels, etc.). |
enrich_providers |
list |
["deezer", "apple", "qobuz", "tidal"] |
Priority order of metadata providers to attempt. |
qobuz_token |
str |
None |
Optional Qobuz user auth token used as fallback for metadata resolution. |
Filename Format Placeholders
When customizing the filename_format string, you can use the following dynamic tags:
{title}- Track title{artist}- Track artist{album}- Album name{track}- Track number{date}- Full release date (e.g., YYYY-MM-DD){year}- Release year (e.g., YYYY){position}- Playlist position{isrc}- Track ISRC code{duration}- Track duration (MM:SS)
Want to support the project?
If this software is useful and brings you value, consider supporting the project by buying me a coffee. Your support helps keep development going.
API Credits
Song.link · hifi-api · dabmusic.xyz · SpotubeDL · afkarxyz
[!TIP]
Star Us, You will receive all release notifications from GitHub without any delay ~
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spotiflac-0.3.3.tar.gz.
File metadata
- Download URL: spotiflac-0.3.3.tar.gz
- Upload date:
- Size: 62.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5e6d87f3f47ac9a81a7ec2d801589afaaf0a29b4763413d5918206feff5a14e
|
|
| MD5 |
17aacd417ed968e69f404366ad85e2d2
|
|
| BLAKE2b-256 |
54af62ca1173ba6b546c2e321f8e9fd9509cacfa8bbbcb9a2646095fb2401c28
|
File details
Details for the file spotiflac-0.3.3-py3-none-any.whl.
File metadata
- Download URL: spotiflac-0.3.3-py3-none-any.whl
- Upload date:
- Size: 71.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2c439fda64525ca82c70b1e3ec20ebf4e9a10e7d93fe4ad863506060d9876d7
|
|
| MD5 |
50681254b995a677e77632a4517a7da9
|
|
| BLAKE2b-256 |
66e3e01118c499bbad84bd0d2b458038557234ce58257c6b02afddd008d51219
|