Skip to main content

A command line interface for Spotify

Project description

Spotify Command Line

Table of Contents

Introduction

A bit ago, I installed ohmyzsh onto my mac, and while looking at the plugins I stumbled across the macos plugin. There also was a sub-plugin in there to control Spotify from the command line, but I didn't like it for two main reasons: it controlled Spotify through AppleScript as opposed to the Spotify API, and it didn't have the feature to queue songs. I would've been able to live with the first reason, since I only have my macbook, but not being able to queue songs was a deal breaker for me, as I'm not trying to delete my whole queue or switch to a different playlist every time I want to listen to a song. So I decided to make my own command line program to control Spotify! Unlike the ohmyzsh plugin, this program uses the Spotify API (through Spotipy) to control Spotify, so any computer that has Python and Spotify installed can use this program.

Installation & Setup

Installation

To install, run the following command:

pip install spotifycl

You must already have Python installed on your computer.

Setup

To setup the program, you need to have a spotify account (obviously), and you'll have to create a new app on the Spotify Developer Dashboard. Once you've created the app, find the Client ID and Client Secret in the app's settings, and then run the program in the terminal by typing spotifycl and follow the instructions. Once you've done that, you should be good to go!

Uses

You can run the program by typing spotifycl into your terminal. You can also run the program with the -h or --help flag to get a list of all the commands and their descriptions. Spotify needs to be open and running on a device for the program to work.

Try to be as descriptive as possible when passing in the name of a playlist, album, artist, or song, because the program will find the first item that matches the name you pass in. And make sure you put quotes around any arguments that have any spaces. For example, if I try to play Time by Pink Floyd by running spotifycl play time, it plays Time of Our Lives by Pitbull. While I love some Pitbull, that's not what I wanted to listen to. So if I run spotifycl play "time pink floyd", it plays Time by Pink Floyd.

Commands

play

There are 6 different ways to use the play command: play, play song, play album, play artist, play playlist, and play uri.

You can run any of them like so:

spotifycl play {--album|--band|--playlist|--uri} {song|album|band|playlist|uri}
play

This command will pause or play the current song depending on whether or not it's already playing.

spotifycl p
play song

This command will play the first song that matches the name of the song you pass in.

spotifycl p "song name"
play album

This command will play the first album that matches the name of the album you pass in.

spotifycl p -a "album name"
play artist

This command will play the first artist that matches the name of the artist you pass in.

spotifycl p -b "artist name"
play playlist

This command will play the first playlist that matches the name of the playlist you pass in.

spotifycl p -p "playlist name"
play uri

This command will play the song, album, artist, or playlist that matches the uri you pass in.

spotifycl p -u "uri"

queue

There are 4 different ways to use the queue command: queue song, queue album, queue playlist, and queue uri.

You can run any of them like so:

spotifycl queue {--album|--playlist|--uri} {song|album|playlist|uri}
queue song

This command will queue the first song that matches the name of the song you pass in.

spotifycl q "song name"
queue album

This command will queue the first album that matches the name of the album you pass in.

spotifycl q -a "album name"
queue playlist

This command will queue the first playlist that matches the name of the playlist you pass in.

spotifycl q -p "playlist name"
queue uri

This command will queue the song, album, or playlist that matches the uri you pass in.

spotifycl q -u "uri"

next

This command will skip to the next song in the queue.

spotifycl {n|next}

back

This command will go back to the previous song in the queue.

spotifycl {b|back}

status

This command will print out the information about the current song.

spotifycl {s|status}

It prints out the song, artist, album, and the current time of the song.

volume

This command will either set the volume to the number you pass in, or it will print out the current volume.

spotifycl {v|volume} [number]

shuffle & repeat

These commands will either turn on or off shuffle and repeat.

spotifycl {t|toggle} {-s|--shuffle|-r|--repeat}

Quality Assurance

All variable, function, class, module, & file names are written in snake_case to make sure everything is consistent, and all const variables are written in ALL-CAPS. The variable names are quite verbose, so it should be easy enough to understand what's going on.

If there are any other/better ways to check for quality assurance, please let me know in the suggestions!

Suggestions

If you have any suggestions about anything, please create a new discussion in suggestions.

Contributing

Contributions are always welcomed! Look at CONTRIBUTING.md for more information.

License

The project is available under the MIT license.

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

spotifyCL-1.3.3.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

spotifyCL-1.3.3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file spotifyCL-1.3.3.tar.gz.

File metadata

  • Download URL: spotifyCL-1.3.3.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for spotifyCL-1.3.3.tar.gz
Algorithm Hash digest
SHA256 c312361cee6a4a1c5ed20cb99b924cc5abcabbaa5ba079c644af0b7270ca6a79
MD5 cb4edad412a84c4ac2f0df8c81c86893
BLAKE2b-256 d734c10457871b6e0620f72258081f805f1e9c3d40f732c54508805b086fa03d

See more details on using hashes here.

File details

Details for the file spotifyCL-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: spotifyCL-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for spotifyCL-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 113331ad388dacf8b4617091f0bd70b0a3fb00d84abc8d16bc79927daedd2580
MD5 bee5fcaea28c565af50c618ef66e9134
BLAKE2b-256 ab11aeeca7ef23b2627282cf901e31b9b824b3f9b8e29de1b09f96a824a6f60e

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