btdl#

btdl is a pure command-line client for Tidal, built on the binary-tidal-py library. It is the command-line surface of the whole library: search the catalog, resolve links, check what a download would do, download collections with resume and per-item failure isolation, stream tracks to stdout or files, and maintain the local library (transcode, probe, purge, diagnose).

No TUI, no global state, no surprise I/O:

  • results go to stdout — an aligned table by default, or the exact JSON payload with --json on every command;

  • progress and errors go to stderr, so a pipe or a jq consumer never sees anything but the payload;

  • exit codes are a stable contract (0 ok, 1 a Tidal error, 130 cancelled, 2 usage/internal — see the output contract);

  • the library’s resume, skip-existing, quality-downgrade chain, and retry behavior comes along for the ride, because btdl is a thin surface over it.

Install#

btdl is published to the binarycollective Forgejo package registry under the name binary-tidal-cli.

$ uv tool install \
    --index-url https://git.binarycollective.de/api/packages/binary/pypi/simple \
    binary-tidal-cli
$ btdl --version

pip works the same way (pip install binary-tidal-cli --index-url https://git.binarycollective.de/api/packages/binary/pypi/simple), as does a source checkout with uv sync --group dev.

System requirement: ffmpeg/ffprobe on PATH for maintain transcode and maintain probe; the download pipeline uses them only for the optional --save-as-flac remux and the --verify-media ffprobe pass (turn both off and downloads need no ffmpeg at all). Everything else works without it.

Quick start#

Log in once (see login for the options):

$ btdl auth device-login
device login
  open:  https://link.tidal.com/activate
  enter: ABCD-EFGH
  ...
logged in as user 1234567

Then browse and grab:

$ btdl search "daft punk" --type albums
$ btdl tracks <album-url>
$ btdl plan <album-url>            # what a download would do
$ btdl download <album-url>        # resume, per-item isolation
$ btdl stream <track-url> -o track.flac

Every one of those also takes --json:

$ btdl search "daft punk" --type albums --limit 5 --json | jq '.items[0].title'

Global options#

Every command accepts the same global options, settable per call or via environment variables. They map one-to-one onto the library’s Config — the full surface is available, so btdl is scriptable the way the library is.

Session#

Option

Env

Default

Meaning

--token, -t

BTDL_TOKEN

library default

the saved-login (token) file

--output, -o

BTDL_OUTPUT

~/Music/btdl

the download output root

--quality, -q

BTDL_QUALITY

LOSSLESS

LOW, HIGH, LOSSLESS, HI_RES_LOSSLESS, or a label like master (btdl qualities lists the labels and ladders); an unknown label fails fast

--client

BTDL_CLIENT

library default

OAuth client id (btdl auth clients); an unknown id fails fast (zero traffic)

--proxy

BTDL_PROXY

none

proxy URL for the transport

--timeout-connect

—

10.0

connect timeout, seconds

--timeout-read

—

60.0

read timeout, seconds

--verbose, -v

—

off

DEBUG logging on stderr (secret-redacted via the library’s RedactionFilter)

--version

—

—

print the version and exit

--install-completion

—

—

install tab completion for the current shell

--show-completion

—

—

print the completion script (copy/customize)

Naming and collection behaviour#

Option

Env

Default

Meaning

--track-format

BTDL_TRACK_FORMAT

{number} {artist} - {title}{explicit}

the track filename path template

--album-format

BTDL_ALBUM_FORMAT

{artist} - {album} {year}

the album directory path template

--playlist-format

BTDL_PLAYLIST_FORMAT

Playlist - {title}

the playlist/mix directory path template

--include-ep / --no-include-ep

BTDL_INCLUDE_EP

on

include EPs and singles in artist downloads

--quality-priority

BTDL_QUALITY_PRIORITY

none

comma-separated custom playback ladder — it replaces the built-in downgrade chain, the profile’s own rung included (a rung the order omits is never asked, e.g. HIGH,LOSSLESS); a rung the track’s catalog ceiling cannot serve is dropped from the attempts

--skip-broken / --no-skip-broken

BTDL_SKIP_BROKEN

on

keep going past broken items (a per-run --fail-fast overrides it)

Network#

Option

Env

Default

Meaning

--max-retries

BTDL_MAX_RETRIES

3

retries per transient request failure

--retry-backoff

BTDL_RETRY_BACKOFF

1.0

retry backoff base, seconds

--rate-limit-max-wait

BTDL_RATE_LIMIT_MAX_WAIT

90.0

429 wait budget per logical request, seconds

--rate-limit-max-pause

BTDL_RATE_LIMIT_MAX_PAUSE

21600.0

cumulative cap for long server-requested pauses, seconds

--request-interval

BTDL_REQUEST_INTERVAL

0.0

proactive pacing between playback resolutions (0 = adaptive-only)

--asset-not-ready-max-waits

BTDL_ASSET_NOT_READY_MAX_WAITS

6

polls to wait for an asset still being prepared

--user-agent

BTDL_USER_AGENT

none

a custom User-Agent for the transport

--no-verify-tls

BTDL_NO_VERIFY_TLS

off

disable TLS certificate verification (dangerous)

--ca-bundle

BTDL_CA_BUNDLE

none

a custom CA bundle path (corporate MITM proxies); mutually exclusive with --no-verify-tls

--api-base / --legacy-api-base / --openapi-base / --auth-base

BTDL_API_BASE / BTDL_LEGACY_API_BASE / BTDL_OPENAPI_BASE / BTDL_AUTH_BASE

none

base-URL overrides (replay proxies, testing)

Downloads#

Option

Env

Default

Meaning

--download-workers

BTDL_DOWNLOAD_WORKERS

8

byte-range fetch workers per track (distinct from the per-run --workers track parallelism)

--part-size

BTDL_PART_SIZE

1 MiB

part size for parallel range fetches, bytes (64 KiB–32 MiB)

--pacing-bps

BTDL_PACING_BPS

none

throttle download throughput, bits/s

--no-validate-media-urls

BTDL_NO_VALIDATE_MEDIA_URLS

off

disable the SSRF guard on manifest-supplied media URLs (replay proxies only)

--output-lock-timeout

BTDL_OUTPUT_LOCK_TIMEOUT

300.0

seconds to wait for the output directory lock when another btdl/host writes the same tree

Post-processing#

Option

Env

Default

Meaning

--write-tags / --no-write-tags

BTDL_WRITE_TAGS

on

write audio tags (ID3v2.4 / MP4 / FLAC) to finished files

--write-lyrics

BTDL_WRITE_LYRICS

off

fetch per-track lyrics and embed them (one extra API call per item)

--lyric-file

BTDL_LYRIC_FILE

off

write a lyric sidecar (.lrc when timed, .txt otherwise) next to each file

--download-cover / --no-download-cover

BTDL_DOWNLOAD_COVER

on

embed collection artwork and write a cover.jpg sidecar

--save-album-info

BTDL_SAVE_ALBUM_INFO

off

write an AlbumInfo.txt after each album download

--save-as-flac / --no-save-as-flac

BTDL_SAVE_AS_FLAC

on

remux FLAC-in-MP4 to true FLAC when ffmpeg is available

--verify-media / --no-verify-media

BTDL_VERIFY_MEDIA

on

ffprobe-verify the delivered bytes against the manifest facts

--save-receipts

BTDL_SAVE_RECEIPTS

off

write completion receipts; skip only receipt-proven files (the quality-aware skip/upgrade path)