A command line application, written in Python, for interacting with Spotify.

Overview

spotify-py-cli

A command line application, written in Python, for interacting with Spotify.

The primary purpose behind developing this app was to gain experience in using Test Driven Development, and to familiarize myself with the spotify API.

NOTE: This app is still a work in progress and as such, some of the info in this doc may be subject to change.

How To Use

First, follow the steps in Setup.

Once you have an executable, or you've downloaded the source, and have a terminal open, run it! With Python:

python spotify-cli.py

Using exe with Windows:

.\spotify-cli

Linux:

./spotify-cli

Running it without any arguments will in typical command line fashion show usage help. Run any command without args to get specfic help for any given command.

Supported Functionality

Currently with this cli you can do the following:

  • Create new playlists
    • You can set the name, description, public status, and collaborative status
  • Edit any existing playlists you own, or are a collaborator on
  • Add and remove items from your user library
    • This includes followable items like artists and playlists, as well as savable items like albums, tracks, episodes and shows
    • Currently following, unfollowing, saving, and unsaving are all seperate commands
  • Show (list) items currently in your user library
    • Supports all followable/savable items

Future Functionality

Here are features that I want to add in the very close, to near future:

The biggest one in mind is playback support. I may add other smaller things, but this is the primary thing I don't have yet that I want to add. Here's a more detailed list of what I'm looking to add:

  • Playback support

    • Be able to play and pause playback of the current track
    • 'play' command will also accept a track id so you can start playback of a new track
    • Be able skip to next track
    • Be able to toggle shuffle on and off
    • Seek position in a track
    • Set volume
    • Add an item to the playback queue (passing multiple track ids to 'play' will also do this)
  • Easy-to-parse output

    • Any command that returns output, will have an option to make the output easy to parse (vs being nice to look at for a human). The idea being, if you want to pipe output from one command invocation, into another invocation, you can.
    • An example I'd like to be able to support, get a list of track ids from search command, and then pipe those into the playback command.

Design

This a very brief overview of my program design, bug me if you want me to expand this. I'll probably expand it at some point in the future.

Broadly speaking, the cli spotify-cli.py depends only on one thing, a facade. The facade spotipy_facade.py is a wrapper I wrote around spotipy which is itself a wrapper written around the Spotify API. See Figure 1.1 for a visual layout of the modules.

I wrote the facade to further simplify interaction (and seperate my cli app from) the wrapper.

The facade itself is comprised of three modules: spotify_facade.py, the main file, items.py, and user_library.py.

items.py, and user_library.py both contain item types which the facade works with, and returns to the cli based on what commands are being run. The types in those two files are the basis for all interaction with the api.

The types defined in items.py, and user_library.py implement interfaces as defined in interfaces.py.

Figure 1.1 fig1.1

Setup

First, you must get authorization.

For simplicity, and because Spotipy doesn't support Implicit Grant authorization, to use this cli, you must register an app using the Spotify Developer Dashboard so that the app can use Authorization Code flow:

  1. Log in
  2. Click the CREATE AN APP button in the top right corner
  3. Once you have created your app, on the app overview page, click EDIT SETTINGS
  4. Set the Redirect URI to http://localhost:8080 (You can change this to something else like: http://example.com, or http://127.0.0.1:9090, but it has to be the same in the app settings page and in the .env file)
  5. Note that the Client ID and Client Secret are also on the app overview page; these will be used later

Next, you have two options: Use a standalone release, or use Python.

Using a Standalone Release: COMING SOON

Note: I haven't made any standalone releases yet. If you really want one, open an issue to bug me about it.

Or, you can use pyinstaller to build a standalone app yourself; it's what I'll be doing when I get around to it.

If you don't want to install Python onto your system, you can download an existing standalone build of the app from the releases page.

  1. Download the latest release from the releases page
  2. See step 3 of Using Python

Using Python

  1. Clone the repo
  2. Install Python 3.8 or greater
    • Note: This app was built using Python 3.8 and 3.96, but it may work with older versions; I have not tested anything older than 3.8 so I can't make any guarentees for anything older than that.
  3. Create a credentials file
    1. Retrieve your Client ID and Client Secret from the app overview page
    2. Create .env file and place it into the same directory as the source code (or exe if using a standalone release)
    3. Place the following text into the .env file:
      SPOTIPY_CLIENT_ID=Your_Spotify_Client_ID
      SPOTIPY_CLIENT_SECRET=Your_Spotify_Client_Secret
      SPOTIPY_REDIRECT_URI=http://localhost:8080
      
  4. If Python is in the path, then navigate to the directory the app is in and run the app with:

    py spotify-cli.py

Credits

This project uses Spotipy for interacting with the Spotify API, and Typer for managing the CLI bits.

Owner
Drew Loukusa
UW-Bothell Alum with a bachelor's degree in Applied Computing (Computer Science Major + Math Minor).
Drew Loukusa
Container images for portable development environments

Docker Dev Spin up a container to develop from anywhere! To run, just: docker run -ti aghost7/nodejs-dev:boron tmux new Alternatively, if on Linux: p

Jonathan Boudreau 163 Dec 22, 2022
Trans is a dependency-free CLI for Google Translate

Trans is a dependency-free CLI for Google Translate

11 Jan 04, 2022
A simple python script to execute a command when a YubiKey is disconnected

YubiKeyExecute A python script to execute a command when a YubiKey / YubiKeys are disconnected. ‏‏‎ ‎ How to use: 1. Download the latest release and d

6 Mar 12, 2022
Detect secret in source code, scan your repo for leaks. Find secrets with GitGuardian and prevent leaked credentials. GitGuardian is an automated secrets detection & remediation service.

GitGuardian Shield: protect your secrets with GitGuardian GitGuardian shield (ggshield) is a CLI application that runs in your local environment or in

GitGuardian 1.2k Jan 06, 2023
CLTools provides various tools and command to use in the terminal.

CLTools provides various tools and command to use in the terminal. As of date, CLTools is only able to generate temporary email addresses and receive emails. There are plans to integrate more tools a

Ashwin Chugh 2 Feb 14, 2022
Interactive Redis: A Terminal Client for Redis with AutoCompletion and Syntax Highlighting.

Interactive Redis: A Cli for Redis with AutoCompletion and Syntax Highlighting. IRedis is a terminal client for redis with auto-completion and syntax

2.2k Dec 29, 2022
Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

Charles Tapley Hoyt 11 Feb 11, 2022
Analysis of a daily word game "Wordle"

Wordle Analysis of a daily word game "Wordle" https://www.powerlanguage.co.uk/wordle/ Description Worlde is a daily word game in which a player attemp

Bartek 1 Feb 07, 2022
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

18.6k Dec 30, 2022
A simple automation script that logs into your kra account and files your taxes with one command

EASY_TAX A simple automation script that logs into your kra account and files your taxes with one command Currently works for Chrome users. Will creat

leon koech 13 Sep 23, 2021
A project designed to make taking notes easier than ever - by doing it all on command line

A project designed to make taking notes easier than ever - by doing it all on command line! Yes, all of your files are easily accessible through one command interface, and can be written to at any ti

1 Dec 10, 2021
A command line tool to create a graph representing your Ansible playbook tasks and roles

Ansible Playbook Grapher ansible-playbook-grapher is a command line tool to create a graph representing your Ansible playbook plays, tasks and roles.

Mohamed El Mouctar Haidara 424 Dec 20, 2022
A very simple and lightweight ToDo app using python that can be used from the command line

A very simple and lightweight ToDo app using python that can be used from the command line

Nilesh Sengupta 2 Jul 20, 2022
A tool to automatically convert old string literal formatting to f-strings

flynt - string formatting converter flynt is a command line tool to automatically convert a project's Python code from old "%-formatted" and .format(.

Elijah K 551 Jan 06, 2023
A Python package for Misty II development

Misty2py Misty2py is a Python 3 package for Misty II development using Misty's REST API. Read the full documentation here! Installation Poetry To inst

Chris Scarred 1 Mar 07, 2022
Wordle breaker: A CLI tool to help you solve Wordle

Wordle Breaker A CLI tool to help you solve Wordle I decided to code a solution

Alex 4 Apr 27, 2022
Enlighten Progress Bar is a console progress bar library for Python.

Overview Enlighten Progress Bar is a console progress bar library for Python. The main advantage of Enlighten is it allows writing to stdout and stder

Rockhopper Technologies 265 Dec 28, 2022
Command Line For Truecaller Written In Python

Truecaller-CLI Command Line Version For Truecaller Written In Python Never Login With A Number Over And Over Or It Will Be Banned Because Program Is S

Sandaru Ashen Fernando 16 Nov 08, 2022
A super simple terminal command shortener 🐟

pcmd A super simple terminal command shortener 🐟 Source code : https://github.com/j0fiN/pcmd Documentation : https://j0fin.github.io/pcmd About Durin

9 Mar 02, 2022