Skip to main content

A modern CLI for collecting Spotify listening data.

Project description

esporifai

PyPI Changelog Tests License

A modern CLI for collecting Spotify listening data from the Spotify Web API.

Installation

Install this tool using pip:

pip install esporifai

For development:

python -m pip install -e '.[dev]'

Usage

For help, run:

esporifai --help

You can also use:

python -m esporifai --help

Recently played tracks

To retrieve recently played tracks, run:

esporifai get-recently-played

For help,

esporifai get-recently-played --help

Authentication

esporifai uses Spotify authorization code flow and stores auth artifacts in your app config directory.

Required environment variables:

SPOTIFY_CLIENT_ID=...
SPOTIFY_AUTH_STRING=...
REDIRECT_URI=...
USERNAME=...  # or SPOTIFY_USERNAME
PASSWORD=...  # or SPOTIFY_PASSWORD

For stable automation, prefer a long-lived refresh token:

SPOTIFY_REFRESH_TOKEN=...

Useful auth commands:

esporifai auth --check
esporifai auth --status
esporifai auth --url
esporifai auth --code <authorization-code>
esporifai auth --force

esporifai will use auth in this order:

1. cached access token
2. cached refresh token
3. SPOTIFY_REFRESH_TOKEN from the environment
4. browser login flow

Optional runtime tuning:

ESPORIFAI_REQUEST_TIMEOUT_SECONDS=30
ESPORIFAI_BROWSER_SLOW_MO_MS=300
ESPORIFAI_LOGIN_TIMEOUT_MS=30000
ESPORIFAI_CONSENT_TIMEOUT_MS=5000
ESPORIFAI_REDIRECT_TIMEOUT_MS=90000

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd esporifai
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

python -m pip install -e '.[dev]'

To run the tests:

python -m pytest -m "not integration"

To run the live Spotify integration tests:

python -m pytest -m integration

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

esporifai-0.3.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

esporifai-0.3.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: esporifai-0.3.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for esporifai-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6b15a689aa942123e8efc7fbf221a3c03d8730787a4a52fa471e6b18dedb833d
MD5 4067acb7c96328d567148731e4ddbbea
BLAKE2b-256 a0126b292448d21c7a14ad0db7ede80580f9464096b835a9f4421a6dfcfde90f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: esporifai-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for esporifai-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8337d209102975eb940c816af6f874349fa2da3c58ef9120c5c1e6aa01865f8
MD5 7900fff27115b7d60bbd6d1264d01626
BLAKE2b-256 cd21ed1dbbf27377d947cb1d3f3336ac8746b2d1857cea0e629e9effd57c72a8

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