Skip to main content

A boring Spotify CLI client

Project description

Spotidry

Summary

Spotidry is a real dry & boring command-line client for Spotify.

My main motivation for this project is to have a simple client that allows me to save the currently-playing song to my Liked Tracks. I also added play/pause/next/previous commands.

One of the best use cases for spotidry is to integrate it into a polybar/tmux/vim status line. You can also map some key-bindings or foot-pedals to send spotidry command.

Below, is a demo video showing some basic spotidry commands, along with a tmux integration.

Installation

It is recommended to install spotidry using uv:

uv tool install -e .

Alternatively, you can install from PyPI:

pip install --user spotidry
spotidry --setup

Note: I have only tested spotidry on Linux.

Development

To set up a local development environment:

  1. Clone the repository:

    git clone https://github.com/mikeboiko/spotidry.git
    cd spotidry
    
  2. Install the tool in editable mode:

    uv tool install --editable .
    
  3. Run type checking:

    uv run basedpyright spotidry
    

Deployment

The deployment process to PyPI and GitHub Releases is automated via GitHub Actions.

Manual Steps

To trigger a new release:

  1. Update Changelog: Add release notes for the new version in CHANGELOG.md.
  2. Bump Version: Update the version number in spotidry/__init__.py.
  3. Commit & Push: Commit these changes and push to the master branch.

Automated Steps

Once the tag is pushed, the GitHub Action will automatically:

  1. Build the package (sdist and wheel).
  2. Check the package metadata with twine.
  3. Create a GitHub Release with the built artifacts and auto-generated notes.
  4. Publish the package to PyPI.

Note: Ensure the PYPI_API_TOKEN secret is set in the GitHub repository settings.

Setup

Spotify API

You will need to register your app at My Dashboard to get the credentials necessary to make authorized calls (a client id and client secret). Select the Web API scope.

You can set your redirect URI to something like "http://127.0.0.1:9999"

Configuration

Configure your Spotify API variables in ~/.config/spotidry/spotidry.yaml

client_id: '<ID>'
client_secret: '<SECRET>'
redirect_uri: 'http://127.0.0.1:9999'
output_format: '{play_symbol} {artist_song} {liked_symbol}'

# Optional: scrolling for long titles (meant for 1Hz status lines like tmux/polybar)
max_width: 30
scroll_speed: 0.5
scroll_gap: '   '

# Optional: reuse recent playback data between CLI invocations
status_cache_seconds: 5

The output_format string supports the following placeholders:

  • {artist}: Artist name
  • {song}: Track title
  • {artist_song}: Convenience string of "{artist} - {song}" (and the one that scrolls)
  • {play_symbol}: Play/Pause indicator (▶ or ⏸)
  • {liked_symbol}: Liked status indicator (❤ or ♡)

Use status_cache_seconds to control how often spotidry asks Spotify for fresh playback data. The default of 5 keeps 1 Hz status bars smooth while limiting Spotify requests to about once every 5 seconds. Increase the value if you still hit rate limits, or set it to 0 to fetch fresh data on every run.

Recent playback data is cached in ~/.cache/spotidry/status_cache.json. If Spotify temporarily returns a rate limit response, spotidry will continue showing the most recent cached status instead of waiting on a long retry.

Tmux Integration

Example for the popular .tmux config:

tmux_conf_theme_status_right='#(flock -n /tmp/spotidry.lock spotidry 2>/dev/null; sleep 1) #{prefix}#{pairing} #{?battery_status, #{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} , %R , %d %b | #{username}#{root} | #{hostname} '

This example redraws once per second for smooth scrolling. With the default status_cache_seconds: 5, Spotify is still refreshed only about once every 5 seconds.

If 1 Hz scrolling is not necessary, increase the shell sleep to reduce API traffic even further.

Polybar Integration

Add the following module to ~/.config/polybar/config.ini

[module/spotidry]
type = custom/script
exec = ~/.local/bin/spotidry
exec-if = test -f ~/.local/bin/spotidry
click-left = ~/.local/bin/spotidry --next 2> /dev/null
click-middle = ~/.local/bin/spotidry --save 2> /dev/null
click-right = ~/.local/bin/spotidry --play 2> /dev/null
interval = 1

This example uses interval = 1 for smooth scrolling. With the default cache settings, Spotify is still refreshed only about once every 5 seconds.

To reduce API traffic further, either raise status_cache_seconds or increase the Polybar interval.

Polybar screenshot

Usage

The first time you run spotidry, you will be prompted to authorize the app in your browser.

Run spotidry --help to see all commands/options.

usage: spotidry [-h] [-v] [-s] [-p] [-n] [--previous]

Spotify CLI client

options:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exit
  -s, --save     toggle liked track status
  -p, --play     play/pause track
  -n, --next     play next track
  --previous     play previous track/skip to beggining of current track

Note, in order to re-authorize, delete ~/.cache/spotidry.yaml... Yes, I will provide a CLI flag for this eventually.

Roadmap

  • Save currently playing song to Liked Tracks
  • Add output string customization
  • Scrolling Text for Long Titles
  • Add volume controls/status
  • Add socks/https proxy option

Contributions

Contributions are always welcome!

Feel free to submit an issue or a pull request.

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

spotidry-0.0.10.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

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

spotidry-0.0.10-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file spotidry-0.0.10.tar.gz.

File metadata

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

File hashes

Hashes for spotidry-0.0.10.tar.gz
Algorithm Hash digest
SHA256 d1ff4dc42c2ab89900f8f4e2580b681eda7543595880673fe0dbe4ef1cf73d8d
MD5 8bc2a78ba28f3c8daa3156d05f80ca1c
BLAKE2b-256 8aa6829a4396d5fab6d8121015b9b4b429d34f7d89209cdddfe06e037900d2c6

See more details on using hashes here.

File details

Details for the file spotidry-0.0.10-py3-none-any.whl.

File metadata

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

File hashes

Hashes for spotidry-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 585a58423de02851a73361f8af35b347b5f7534b86d270b4f14c00f9ee47dd13
MD5 87da56109d0a353ecd0909c92941ad10
BLAKE2b-256 9e5cd6019440c34e146999de6e76cdfdb8a3cd35bdfedaf9120a7b87002550dc

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