CLI interface for tidalpy https://btdl.natz.club
Find a file
Daniel Malik a14dfe5be3
All checks were successful
CI / Docs (push) Successful in 14s
CI / Lint (push) Successful in 15s
CI / Test (Python 3.13) (push) Successful in 6m10s
docs: the LLM-facing Markdown twins, the Dockerized site, untracked build output
The docs parity work (built and verified green by the docs
agent):

- sphinx-llm twins: llms.txt, llms-full.txt, a .html.md per
  page; every page carries a :description: meta block inside
  an {eval-rst} fence (MyST v4 does not parse a bare
  .. meta:: directive in Markdown) — feeds the llms.txt
  sitemap and the head description meta;
- the new recipes page joins the command surface docs;
- deployment: docs/Dockerfile (Sphinx build stage + nginx
  runtime, port 80) for Coolify, docs/docker-compose.yml,
  docs/nginx/btdl-docs.conf; the runtime container needs no
  env vars, the optional build args are BTDL_VERSION and
  GIT_COMMIT;
- docs/_templates/components/ overrides the footer (the
  vX.Y.Z-<shorthash> form; GIT_COMMIT for container builds)
  and the Open Graph head;
- the build output is no longer tracked (gitignored; the
  tracked docs/_build/html tree removed from the index) —
  CI builds it with sphinx-build -b html -W as before;
- the sphinx-llm dev dependency (uv.lock), the README's
  documentation link, and the AGENTS.md docs section.
2026-11-29 05:51:47 +01:00
.forgejo/workflows build: require binary-tidal-py 0.2.9 (Python >=3.13) 2026-11-24 00:55:42 +01:00
docs docs: the LLM-facing Markdown twins, the Dockerized site, untracked build output 2026-11-29 05:51:47 +01:00
src/btdl refactor: the artist videos human view through the house table 2026-11-25 22:51:13 +01:00
tests test: download-many's duplicate-link dedupe 2026-11-29 05:51:46 +01:00
.flake8 chore: scaffold btdl (core, workflows, reference ids command) 2026-11-23 02:38:51 +01:00
.gitignore docs: the LLM-facing Markdown twins, the Dockerized site, untracked build output 2026-11-29 05:51:47 +01:00
AGENTS.md docs: the LLM-facing Markdown twins, the Dockerized site, untracked build output 2026-11-29 05:51:47 +01:00
pyproject.toml docs: the LLM-facing Markdown twins, the Dockerized site, untracked build output 2026-11-29 05:51:47 +01:00
README.md docs: the LLM-facing Markdown twins, the Dockerized site, untracked build output 2026-11-29 05:51:47 +01:00
uv.lock docs: the LLM-facing Markdown twins, the Dockerized site, untracked build output 2026-11-29 05:51:47 +01:00

btdl

A pure command-line Tidal client on the tidalpy library — authentication, catalog browsing, search, and the full download pipeline (progress, reports, resume, retag, transcode) as plain commands.

No TUI: stdout carries the result (a JSON payload with --json, aligned tables otherwise), progress and errors go to stderr.

Documentation

Install

# from the Forgejo package registry
pip install binary-tidal-cli --extra-index-url https://git.binarycollective.de/api/packages/binary/pypi/simple

# or a dev checkout (uv)
git clone ssh://git.binarycollective.de/binary/binary-tidal-cli.git
cd binary-tidal-cli
uv sync --group dev

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

Quick start

btdl auth device-login          # one-time login (shows a URL + code)
btdl auth status                # who's logged in, what the plan allows
btdl search "radiohead" --type album
btdl resolve https://tidal.com/album/1234
btdl -q master download https://tidal.com/album/1234
btdl download --json https://tidal.com/track/5678 | jq .ok

Global options

Every command accepts these (before the command name):

Flag Meaning
--token, -t Saved-login file ($BTDL_TOKEN, else the library default)
--output, -o Download output root ($BTDL_OUTPUT, else ~/Music/btdl)
--quality, -q LOW/HIGH/LOSSLESS/HI_RES_LOSSLESS or a label: master, flac, 24/192, ... ($BTDL_QUALITY)
--client OAuth client_id from the registry (btdl auth clients)
--proxy Proxy URL for the transport ($BTDL_PROXY)
--timeout-connect / --timeout-read Transport timeouts (s)
--verbose, -v DEBUG logging on stderr (secret-redacted)
--version Print the version and exit
--install-completion / --show-completion Tab completion for the current shell (install, or print the script)

That's the session core. The full global surface — filename templates (--track-format, --album-format, --playlist-format), the playback ladder (--quality-priority), retry/429 knobs (--max-retries, --rate-limit-*, --request-interval), TLS and base-URL overrides, download mechanics (--download-workers, --part-size, --pacing-bps, --output-lock-timeout) and the post-processing toggles (--write-lyrics, --save-receipts, --save-album-info, --no-save-as-flac, ...) — is the library's Config field for field, each with a BTDL_* env var. See the docs or btdl --help.

Every command also accepts --json (after the command name): print the machine-readable JSON payload to stdout instead of the human table. The batch verbs (resolve-many, plan-many, download-many) also accept @FILE (a link-list file) and - (stdin) in place of links.

Command tree

Command What it does
btdl search QUERY Catalog search (--type, --limit, --offset, --country)
btdl search-all QUERY Page through a search to exhaustion (--page-size, --max-items)
btdl search-albums QUERY Album search that understands artist names (--prefer-atmos)
btdl autocomplete QUERY Search-box suggestions
btdl genres / btdl genre-items GENRE The browse (Discover) grid and one genre's items
btdl resolve URL Any link → kind/id/title/link
btdl metadata URL The full catalog record (the wire dict)
btdl resolve-many URL... Batch resolution with per-link isolation
btdl tracks URL A link's tracks (album, playlist, mix, artist, track)
btdl artwork ITEM --out FILE Fetch cover art bytes (--size)
btdl artwork-url ID Build the CDN URL for an artwork id (offline)
btdl lyrics URL Plain lyrics + timed subtitles for a track
btdl credits URL / btdl contributors URL Album credits / track contributors
btdl radio URL The "Play Radio" queue for a track or artist
btdl atmos URL The Dolby Atmos catalog twin of an album or track
btdl video URL A video link's card facts (metadata only)
btdl invalidate Drop the item-list caches of this run
btdl playback URL What will actually play (quality, codec, rate, CDN link)
btdl playback-many ID... Batch playability pre-flight
btdl by-isrc ISRC The track an ISRC identifies
btdl artist albums|tracks|top|similar|videos URL An artist's discography and pages
btdl album similar|credits URL An album's related pages
btdl ids tracks|albums|artists|playlists ID... Bulk lookups by catalog id
btdl ids album-by-upc UPC / albums-by-upcs UPC... The UPC index
btdl ids tracks-by-isrcs ISRC... The ISRC index
btdl user profile|playlists [USER_ID] A user's profile card and playlist links
btdl user liked-tracks|liked-albums|liked-artists [USER_ID] The "Liked" tab
btdl download URL Download a track/album/playlist/mix/artist (--dest, --workers, --preview, --retag, --fail-fast); takes the output-dir lock
btdl download-many URL... [@FILE | -] Batch download with per-URL isolation (link-list file or stdin)
btdl list URL [--deep] Item report (deep resolves every stream)
btdl plan URL What a download would do (paths, skip counts)
btdl plan-many URL... [@FILE | -] Batch pre-flight (link-list file or stdin)
btdl qualities The quality profiles, --quality labels and built-in playback ladders (offline)
btdl check FILE URL Does a local file already satisfy the download?
btdl retag URL Re-apply tags/lyrics/cover/replaygain without re-downloading
btdl stream URL [-o FILE] A track's plaintext bytes to a file or stdout
btdl iter-streams URL --dest DIR Stream a collection's tracks to files
btdl maintain transcode SRC DST Re-encode a finished file (--preset cdj2000, or --format + --bitrate/--bit-depth/--sample-rate)
btdl maintain probe FILE ffprobe facts of a local file
btdl maintain purge [--dest DIR] [--older-than S] Remove orphaned .part transfer litter
btdl maintain diagnose Structured self-check (output dir, ffmpeg, ffprobe, token, client) — local, no network
btdl auth Bare: the session state (what auth status does)
btdl auth status|token|ping|subscription Session state (status pings the API, token does not)
btdl auth login [ACCESS_TOKEN] [--user-id N] Save an access token (prompts if omitted)
btdl auth device-login [--timeout S] Device-flow login (shows URL + code, polls)
btdl auth logout Remove the saved login (and revoke remotely)
btdl auth clear Drop the saved login locally only (no revocation)
btdl auth refresh Rotate the access token now (pasted tokens say "nothing to refresh")
btdl auth rate-limit The transport's adaptive pace, as facts
btdl auth clients The registered OAuth clients and their quality tiers
btdl maintain presets The CDJ encoder presets and supported formats (offline)

Exit codes

Code Meaning
0 success (a download report is returned — inspect failures inside it)
1 a typed Tidal error (auth, not-found, rate-limited, ...)
130 a cancellation (Ctrl-C mid-run, or the run's cancel event)
2 a usage error (bad flags) or an internal error (never expected)

--json payloads are the library's own JSON-safe shapes (the facade's snake_case dicts, the models' to_dict wire mirrors) — nothing is re-keyed, so hosts can diff them against the library's.

Development

uv sync --group dev
uv run ruff check . && uv run black --check . && uv run isort --check-only . \
  && uv run flake8 . && uv run mypy src/btdl && uv run pytest

# documentation (deployed at https://btdl.natz.club)
uv run sphinx-build -b html -W docs docs/_build/html

Tests run the real command tree two ways: tests/test_cmd_*.py against a mocked TidalClient (see tests/conftest.py), and tests/test_e2e*.py against a local HTTP stand-in of the Tidal API. No external network, no real tokens. Coverage must stay at or above 90% (--cov-fail-under=90).

Docs container (Coolify)

The Sphinx site ships as a static nginx container; every page's footer shows the build's identity — the version plus the short hash of the commit the site was built from (vX.Y.Z-<shorthash>, the hash whenever it is known):

docker build -f docs/Dockerfile -t btdl-docs .
docker run --rm -p 8080:80 btdl-docs

docs/docker-compose.yml is a ready-made service definition for Coolify (Dockerfile service, port 80). The runtime container needs no environment variables; two optional build args shape the footer — BTDL_VERSION (defaults to pyproject.toml in the build context) and GIT_COMMIT (Coolify wires it from the webhook's CI_COMMIT_SHA). See docs/README.md for the container, the footer, and local builds.