Skip to main content

spdrm

A lightweight Spotify track downloader and mp3 converter.

Research / disclaimer: For educational and research use only, with content and accounts you are authorized to access. The author is not liable for misuse, account issues, data loss, or any other damages.

What it does

Takes a Spotify track URL and downloads the audio (OGG / MP3) using your Premium sp_dc cookie.

Requirements

  • Python 3.10+
  • Spotify Premium + sp_dc cookie
  • FFmpeg (only for MP3 conversion)

Setup

A — raw / local (repo root)

pip install -r requirements.txt
cp .env.example .env

Run from the repo root so import spdrm works (PYTHONPATH=. if needed).

B — optional installable package

pip install -e . # or use pip install spdrm
cp .env.example .env

Same deps as requirements.txt; also installs the spdrm CLI (spdrm → HTTP service).

Edit .env:

SP_DC=
QUALITY=normal
PORT=7331
AUTH_MODE=none
  • Quality: low | normal | high | very-high (default normal)
  • Port: PORT (default 7331) for python api.py / spdrm.api.start()
  • Auth: default examples assume AUTH_MODE=none. For api-key / bearer, set API_KEY and send X-API-Key or Authorization: Bearer …

Usage

Library

import spdrm

url = "https://open.spotify.com/track/3fvY2U1AzW0diYF0hnBbKt?si=747f057de61745d8"

result = spdrm.download(url)
print(result["path"], result.get("time"))

path = spdrm.download_path(url, format="mp3", quality="normal")
ogg = spdrm.download(url, format="ogg")

spdrm.clean()  # clear internal download cache
spdrm.close()

Or use the class:

with Spdrm() as client:
    client.download(url)
    client.clean()

Also available:

search("query")
get_track("3fvY2U1AzW0diYF0hnBbKt")
capabilities()
clean()

API server

Repo root:

python api.py

Or after install:

import spdrm
spdrm.api.start()

Download (sync wait:true includes base64 file by default):

curl -X POST http://localhost:7331/download \
  -H "Content-Type: application/json" \
  -d "{\"input\":\"https://open.spotify.com/track/016z46SJwcRosW9Xb8JKmF\",\"format\":\"mp3\",\"wait\":true}"

Example response:

{
  "trackId": "016z46SJwcRosW9Xb8JKmF",
  "path": "…",
  "file": "<base64 audio bytes>",
  "format": "mp3",
  "bytes": 2400000,
  "cached": false,
  "transcoded": true,
  "lossless": false,
  "time": 1.23,
  "sourceFormat": 1
}

Docker

With .env configured (see Setup):

docker compose up

API on http://localhost:7331 (host port from PORT, default 7331).

TypeScript (save locally)

import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";

const res = await fetch("http://localhost:7331/download", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    input: "https://open.spotify.com/track/016z46SJwcRosW9Xb8JKmF",
    format: "mp3",
    wait: true,
  }),
});

const data = await res.json();
console.log({
  trackId: data.trackId,
  format: data.format,
  bytes: data.bytes,
  time: data.time,
});

await mkdir("./downloads", { recursive: true });
const out = join("./downloads", `${data.trackId}.${data.format}`);
await writeFile(out, Buffer.from(data.file, "base64"));
console.log("saved", out);

Stream / save the binary (no base64):

curl -OJ http://localhost:7331/file/016z46SJwcRosW9Xb8JKmF

Send to a Discord webhook (simplest — save then upload):

# 1) download track (mp3 lands in cwd via -OJ)
curl -OJ http://localhost:7331/file/016z46SJwcRosW9Xb8JKmF

# 2) attach to webhook
curl -F "file1=@016z46SJwcRosW9Xb8JKmF.mp3" "$DISCORD_WEBHOOK_URL"

Or decode the JSON file field first:

curl -X POST http://localhost:7331/download \
  -H "Content-Type: application/json" \
  -d "{\"input\":\"https://open.spotify.com/track/016z46SJwcRosW9Xb8JKmF\",\"format\":\"mp3\",\"wait\":true}" \
  -o result.json

python -c "import json,base64; r=json.load(open('result.json')); open(f\"{r['trackId']}.{r['format']}\",'wb').write(base64.b64decode(r['file']))"

curl -F "file1=@016z46SJwcRosW9Xb8JKmF.mp3" "$DISCORD_WEBHOOK_URL"

MP3 + metadata:

curl -X POST http://localhost:7331/download \
  -H "Content-Type: application/json" \
  -d "{\"input\":\"https://open.spotify.com/track/016z46SJwcRosW9Xb8JKmF\",\"format\":\"mp3\",\"quality\":\"normal\",\"metadata\":\"basic\",\"artwork\":\"thumbnail\",\"wait\":true}"

Raw OGG (includeFile:false if you only need the path / /file/...):

curl -X POST http://localhost:7331/download \
  -H "Content-Type: application/json" \
  -d "{\"input\":\"https://open.spotify.com/track/3fvY2U1AzW0diYF0hnBbKt\",\"format\":\"ogg\",\"includeFile\":false,\"wait\":true}"

Body options

Field Values Default
input track URL / URI / id required
format mp3 | ogg mp3
quality low | normal | high | very-high normal
metadata none | basic | full none
artwork disabled | thumbnail | full disabled
includeFile true | false true when wait:true
wait true | false true

file is base64 audio (capped at 25 MiB by default; use GET /file/{trackId} for larger files or streaming). Prefer saving file to your own folder (see TypeScript example).

Support

Development is currently paused. I’m not planning to provide ongoing support, maintenance, bug fixes, or new updates unless the project receives enough interest and support.

If the repository reaches a sufficient number of stars, I may return to the project and add stuff or release further improvements. Until then, the project should be considered unmaintained.

You can support the project on Ko-fi:

ko-fi

Metadata

Release files for spdrm 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spdrm 1.0.0
File Size Uploaded Provenance Actions
spdrm-1.0.0.tar.gz 38.7 kB Without provenance Details for spdrm-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spdrm 1.0.0
File Interpreter ABI Platform Actions
spdrm-1.0.0-py3-none-any.whl Python 3 none any Details for spdrm-1.0.0-py3-none-any.whl

Total release size: 79.7 kB

Release files / spdrm-1.0.0.tar.gz

Download URL spdrm-1.0.0.tar.gz
Size 38.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4ecac01a991cf9f2c3b22d0ba4009a4412f67f5dcf64c0a390b9a33fb5677ead
BLAKE2b-256 checksum
How to use checksums
a6f533d1801eda2a60e8c9949bb852435f6becc73e39c0afbc1281e3679c3ced
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / spdrm-1.0.0-py3-none-any.whl

Download URL spdrm-1.0.0-py3-none-any.whl
Size 41.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcdea0f23a7fc805aaa5b650cb1cd31a8baabdd08ec1930a3b93f3506ba1b02b
BLAKE2b-256 checksum
How to use checksums
7211ae3e997d7812ea0114b7407be9b2016a784bfab5bee3727ec04acff832f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for spdrm 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page