Skip to main content

djai

Tools for DJ ideation powered by AI/ML. The package ships with a command-line interface that helps you analyse your Spotify likes so you can feed curated metadata into downstream machine-learning workflows.

Command Line Interface

Ensure you have a Spotify access token with the user-library-read scope. You can either pass it as a flag or export it as an environment variable:

export SPOTIFY_API_TOKEN="your-spotify-token"
djai --max-items 100 > liked_tracks.json

Key flags:

  • --token: Provide the Spotify token directly (defaults to SPOTIFY_API_TOKEN).
  • --limit: Batch size per API call (max 50; defaults to 50).
  • --max-items: Optional cap on total tracks to fetch.

The CLI calls Spotify's /v1/me/tracks endpoint, caches responses, downloads MP3 previews via yt-dlp (requires ffmpeg), falls back to a YouTube search when Spotify doesn't expose a preview URL, and runs demucs to separate stems (cached under .djai_cache/stems). Demucs also needs the diffq package; install it alongside Demucs. The command prints the total number of liked tracks retrieved.

.env Support

Store secrets in a .env file to keep them out of your shell history:

SPOTIFY_CLIENT_ID="your-client-id"
SPOTIFY_CLIENT_SECRET="your-client-secret"
SPOTIFY_API_TOKEN="your-spotify-token"

The CLI automatically loads .env from the current working directory (or parent directories) using python-dotenv. If an explicit API token is missing but client credentials are configured, djai launches a one-time Authorization Code flow using a temporary localhost listener to obtain fresh access_token and refresh_token values before fetching tracks. The resulting tokens are cached in .djai_session (ignored by git) so subsequent runs in the same directory reuse them. Downloaded previews are stored under .djai_cache/audio, and API responses are cached under .djai_cache for up to 30 days. Note that analysing a user's liked tracks still requires a token granted with the user-library-read scope.

Development

python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -e ".[dev]"
ruff check .
pytest

Continuous Integration

GitHub Actions runs linting (ruff) and tests (pytest) on pushes and pull requests targeting main via .github/workflows/ci.yml.

Publishing to PyPI

The manual Publish workflow in .github/workflows/deploy.yml builds and uploads the package. Before triggering it, bump the version in pyproject.toml and ensure a PyPI token is stored as PYPI_API_TOKEN.

Metadata

Release files for djai 0.4.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 djai 0.4.0
File Size Uploaded Provenance
djai-0.4.0.tar.gz 11.5 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 23.1 kB

Release files / djai-0.4.0.tar.gz

Download URL djai-0.4.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9dd822e46cbe0057865fa84844f84e019057aa0425ab1646c0cb2bae57829546
BLAKE2b-256 checksum
How to use checksums
7c6e10cf196c6a18ba6e5a202cef73b704f14af91568f622abe7a6557b2b8859
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / djai-0.4.0-py3-none-any.whl

Download URL djai-0.4.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e4afc48c15bea73bca43a4930b48128c48d5f00dd72cd7be3d321884d40036c
BLAKE2b-256 checksum
How to use checksums
cae65c575b551bc9358eb83d58d94cca2e80644fb5c1ac6550e8737058053cec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for djai 0.4.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.

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