Skip to main content

Control Spotify playback on any device through the command line.

Project description

Spotify CLI 🎧

Control Spotify playback on any device through the command line.

Installation

This package only supports Python 3 and above.

$ pip3 install --upgrade spotify-cli

Usage

This CLI performs all interactions through the Spotify API. All you need is a stable internet connection and an active Spotify session on any device.

Authorize the CLI & save your credentials locally.

$ spotify auth login

Start Spotify playback on any device and run the spotify command.

$ spotify
Usage: spotify [<options>] <command>

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  auth      Manage user authentication for spotify-cli.
  browse    Open the current track, album, artist, or playlist in the...
  devices   Manage active devices.
  history   List your recently played tracks.
  next      Play the next track in the queue.
  pause     Pause playback.
  play      Resume playback or search for a track/album/playlist to play.
  previous  Play the previous track in the queue.
  queue     Add a track or album to your queue.
  repeat    Turn repeat on (all/track) or off.
  save      Save a track, album, artist, or playlist.
  search    Search for any Spotify content.
  shuffle   Turn shuffle on or off.
  status    Describe the current playback session.
  top       List your top tracks or artists.
  volume    Control the active device's volume level (0-100).

Examples

Describe and control current playback.

$ spotify play
Playing: Nights
         Frank Ocean - Blonde

$ spotify status -vv
Track   Nights (03:31 / 05:07)
Artist  Frank Ocean
Album   Blonde
Status  Playing (on repeat, 60% volume)

Device  Lorenzo (Smartphone)
URL:    https://open.spotify.com/track/7eqoqGkKwgOaWNNHx90uEZ

$ spotify vol up 20
Volume set to 80%

$ spotify vol to 100
Volume set to 100%

You can also manage multiple devices.

$ spotify devices -v
  LENOVO - Computer
* Lorenzo - Smartphone
  Web Player (Chrome) - Computer

$ spotify devices --switch comp
2 devices matched "comp".
? Please select the device to activate.
 > LENOVO - Computer
   Web Player (Chrome) - Computer

Switched to LENOVO - Computer

Search for a track to play, queue, or save.

$ spotify search red velvet

Search results for "red velvet"

  #  Track                                      Artist
---  -----------------------------------------  ---------------------------
  1  Psycho                                     Red Velvet
  2  Monster                                    Red Velvet - IRENE & SEULGI
  3  Bad Boy                                    Red Velvet
  4  빨간 맛 Red Flavor                         Red Velvet
  5  피카부 Peek-A-Boo                          Red Velvet
  6  Naughty                                    Red Velvet - IRENE & SEULGI
  7  Power Up                                   Red Velvet
  8  Dumb Dumb                                  Red Velvet
  9  Bad Boy - (English Version) [Bonus Track]  Red Velvet
 10  In & Out                                   Red Velvet

Actions:
[n]ext/[b]ack
[p]lay/[q]ueue/[s]ave #[,...]
[a]dd to playlist #[,...] <playlist>
: q 1,4,5

Queue the selected track/s? (1,4,5) [Y/n]: Y
3 track/s queued.

Continue searching? [Y/n]:

Some commands support search queries (play, queue, save).

$ spotify play red velvet
Playing: Psycho
         Red Velvet - ‘The ReVe Festival’ Finale

$ spotify queue --album reve finale
‘The ReVe Festival’ Finale - Red Velvet (16 tracks)
Add this album to the queue? [Y/n]: Y
Album added to queue.

$ spotify save --artist red velvet
Red Velvet
Save this artist to your library? [Y/n]: Y
Following artist - Red Velvet.

Command shortcut prefixes are supported.

# supported
spotify volume
spotify vol
spotify v

spotify next
spotify n

spotify previous
spotify prev

# not supported - too many matches (pause, play, previous)
spotify p

Some commands support the --raw flag to output the Spotify API JSON response (shell script-friendly).

$ spotify status --raw | jq .context
{
  "external_urls": {
    "spotify": "https://open.spotify.com/album/3mH6qwIy9crq0I9YQbOuDf"
  },
  "href": "https://api.spotify.com/v1/albums/3mH6qwIy9crq0I9YQbOuDf",
  "type": "album",
  "uri": "spotify:album:3mH6qwIy9crq0I9YQbOuDf"
}

Notes

  • Playback and device-related commands require at least one active Spotify session on any device.
    • You can just start and stop playback to "activate" your device.
    • Your device will remain "active" even when paused.
  • Some operations may not be supported on certain devices (i.e. volume control for mobile) and for users not subscribed to Spotify Premium.

License

The MIT License (MIT)
Copyright (c) 2020 Benj Ledesma

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

spotify-cli-0.3.3.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

spotify_cli-0.3.3-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file spotify-cli-0.3.3.tar.gz.

File metadata

  • Download URL: spotify-cli-0.3.3.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for spotify-cli-0.3.3.tar.gz
Algorithm Hash digest
SHA256 f9409bf642139a20c4547f0364997a600e9e6f80353b1b7c795d49ffc6a84508
MD5 ce5c8e1b315187e8fd5496dfc9fe18ea
BLAKE2b-256 c814a42d97709963e8d04d6708e4f209fadba3da96043bc06221fd2695fbdbb0

See more details on using hashes here.

File details

Details for the file spotify_cli-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: spotify_cli-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for spotify_cli-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 79d7a63336d2fd07d27ffae96ff9f35d933b33672c90655555bce3579451d586
MD5 5cba1a6c430adac4122620813dd7fff2
BLAKE2b-256 9664d9853778fd6c81022ffa9c94917b292980fed65b8783efc1b751447ea438

See more details on using hashes here.

Supported by

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