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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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