Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spotify CLI 2

A Rust CLI for controlling Spotify playback and queue management via the Spotify Web API.

Features

  • Control playback: pause, resume, next, prev
  • Search and queue tracks with play
  • Show the current queue with show
  • Add the current track to liked songs with add
  • Set volume with vol
  • Transfer playback to a phone device with phone (hardcoded device id)

Prerequisites

  • Rust toolchain (edition 2021)
  • A Spotify account and a Spotify Developer app
  • Spotify app redirect URI set to http://localhost:8080
  • Linux: install libxdo development package (required by enigo)

Setup

  1. Create a Spotify Developer app and note the Client ID and Client Secret.

  2. Update the credentials in src/api_requests/getsessiontoken.rs:

    • client_id
    • client_secret
  3. Create the token directory used by the app:

    mkdir -p database/tokens
  4. Build the CLI:

    cargo build --release

Usage

Run commands with cargo run while developing, or execute the built binary:

cargo run -- <command>
# or
./target/release/spotify <command>

Commands

  • next (optional --count/-c <n>) — skip forward
  • prev — skip backward
  • pause — pause playback
  • resume — resume playback
  • replay — re-queue the current track
  • play [what] [who] — search and queue tracks by title and/or artist
  • show — show queued tracks
  • add — add the current track to liked songs
  • vol [val] — show or set volume (0-100)
  • phone — transfer playback to the hardcoded phone device id

Notes

  • Tokens are stored in database/tokens/ with filenames like admin_access_token.txt and admin_refresh_token.txt.
  • If you want to change the client name used for token storage, update get_client() in src/api_requests/getsessiontoken.rs.
  • The phone command uses a fixed device id in src/api_requests/playback/device.rs; update it for your device.
  • Playback control requires an active Spotify device; the CLI attempts to open Spotify on macOS using AppleScript.

Troubleshooting

  • cargo test or cargo build fails with unable to find library -lxdo on Linux: install the libxdo development package (for example, libxdo-dev). README.md

copilot/update-readme-file Send message What would you like to do next?

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages