Skip to main content

Utilities for working with Django-based AI integrations.

Project description

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), falling back to a YouTube search when Spotify doesn't expose a preview URL, and 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djai-0.3.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

djai-0.3.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file djai-0.3.0.tar.gz.

File metadata

  • Download URL: djai-0.3.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for djai-0.3.0.tar.gz
Algorithm Hash digest
SHA256 74323ccf980237234b526d2c3602b60dd3588adf4f14037acac6de4f4086a451
MD5 a388a248a99d021c214e58d795dff28c
BLAKE2b-256 c8b3400f8bbb2d160235020b6ea5fd54ec3e1a0aaebdbcef96015a74ab16b683

See more details on using hashes here.

File details

Details for the file djai-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: djai-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for djai-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a63e53509fbcf75fa0ce9e750633634044b8da798984ea4c43e89f97def7e382
MD5 25410e3387bc93fb2bd158decb690482
BLAKE2b-256 4c49533d25d2d6c92a9107e140331b43937dea12fb4f28c3764b946b37fa6731

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page