← All projects

Tools

Spotify CLI

A menu-driven terminal interface for your Spotify account. Check what’s playing, search, see your top songs and artists, build playlists from your favorites and spot new releases without leaving the command line. Eight menu options in all.

Spotify CLI terminal menu with options for search, favorites, playlists and new music
Type
Solo project
Category
Tools
Stack
Python · Spotipy · Spotify Web API

Structure

How the parts fit together
Architecture diagram: Terminal and main.py (choice); main.py to menu/ modules (run()); menu/ modules to Spotipy client; Spotipy client and Spotify Web API; main.py to auth.py (at start); auth.py to Spotipy client

On start, auth.py runs the Spotify sign-in and returns one authenticated client. The menu loop then hands that client to whichever module the user picks.

SheetStructure
ProjectSpotify CLI
Parts6

What each menu option does

The app is one numbered menu. Pick an option here the way you would in the terminal. You can also press a number key (1 to 8, or Q) while the menu is focused.

1 Currently Playing

What it does

Asks Spotify what you are listening to right now.

What you see

A "NOW PLAYING" block with the name, first artist, album, release date, whether it is explicit, and the track ID. If nothing is playing, it says so instead. The track ID can be used later in option 8.

2 Search

It asks

  • » Track, album or artist?
  • » Enter the name to search for

What it does

Searches Spotify for tracks, albums or artists, five or ten results at a time (five for artists).

What you see

A numbered list of results. Type a number to open one: an artist shows their top songs and recent releases, an album shows its tracklist, a track shows its details. Type "more" for the next page, or press Enter to go back.

3 List Favorite Songs

It asks

  • » How many songs? (max 50)

What it does

Reads your top tracks from Spotify. Asking for more than 50 just gives you 50, with a joke about it.

What you see

A numbered list of your top songs, each shown as the song name and its artist.

4 List Favorite Artists

It asks

  • » How many artists? (max 50)

What it does

Reads your top artists from Spotify, with the same 50 limit.

What you see

A numbered list of your top artists.

5 Create Playlist from Artists

It asks

  • » Enter artists separated by commas
  • » Create playlist with these songs? (y/n)

What it does

Looks up each artist you typed, collects their top tracks, and shows you the full list before doing anything. If you say yes, it creates a playlist named after what you typed (in capital letters) and adds the songs.

What you see

The songs it is about to add, then a success message once the playlist exists.

6 Create Playlist from Favorite Songs

It asks

  • » How many top songs? (max 50)
  • » Playlist name
  • » Create playlist with these songs? (y/n)

What it does

Takes your top tracks, shows them, and on a yes creates a playlist with the name you chose and adds those songs.

What you see

The list of songs first, then a message that the playlist was created.

7 Check for New Music

It asks

  • » Would you like to create a playlist of these songs? (y/n)

What it does

Looks at the albums and singles from your top 25 artists and keeps the ones released in the last 30 days. If you say yes, it makes a private playlist of all their tracks, named "New Songs" followed by the date.

What you see

A list of releases from oldest to newest, each with the artist, the type (album or single), the name, and how long ago it came out, such as "Today", "3 days ago" or "2 weeks ago".

8 Add Song to Playlist

It asks

  • » Which playlist? (a number)
  • » Enter song IDs (comma-separated)

What it does

Shows your playlists, lets you pick one, and adds the songs whose IDs you typed. The track ID from option 1 or a search works here.

What you see

Your numbered playlists, then a message that the songs were added.

Q Quit

What it does

Leaves the menu loop and ends the program. Anything that is not a menu choice prints "Invalid Input" and shows the menu again.

What you see

A "Goodbye!" message.

To run it you need a Spotify Premium account and your own Spotify developer credentials. Then start it with python main.py.

The problem

Most small Spotify tasks (checking what’s playing, building a playlist from your favorites, seeing whether artists you follow have new music) shouldn’t need the full desktop app. This puts them behind a simple numbered menu in the terminal.

Approach

  • Authenticates with the Spotify Web API through the Spotipy library, reading developer credentials from environment variables
  • An eight-option text menu: currently playing, search, favorite songs, favorite artists, playlist from artists, playlist from favorite songs, check for new music, and add a song to a playlist
  • Organized with one module per menu action, and shared playlist-creation and UI code kept in a separate source folder
  • Needs a Spotify Premium account and developer credentials to control playback

Highlights

  • Playlists generated from your favorite artists or top tracks
  • New-release checks across artists you follow
  • Search for songs, artists and albums from the terminal
  • Modular design: one file per feature

Ask my site

Ask about Spotify CLI.

Answers come only from the content on this site. If it isn't here, it'll say so and point you to my email.

Answers are generated from this site's content, so double-check anything important.

Psst, this page has a cheat code.