BelkaDev / Spotify-Headless

Experimental wrapper for Spotify API to search songs and control the web player using the cli (Feat. Puppeteer)
GNU General Public License v3.0
103 stars 8 forks source link
cli puppeteer spotify

Spotify-Headless

A CLI tool using puppeteer to intercept your own validated spotify OAuth token alongside of the session cookies, then reinject them to mimic an authorized, user-like traffic.

How it works

  1. Establish a session by authenticating to Spotify within a headless browser. (Puppeteer)
  2. Export the session cookies and store them locally, specifically the refresh token that will refresh the JWT every time it expires. (valid for one year)
  3. The access token allows you to perform special actions on behalf of a user.

Installation and configuration

git clone https://github.com/BelkaDev/Spotify-Headless ~/Spotify-Headless
cd ~/Spotify-Headless && npm install

To provide your credentials you need to set them as environement variables within your bashrc (or your default shell rc)

export SPOTIFY_USER=""
export SPOTIFY_PWD=""

Running

Manually grab your access token: node token.js
Other commands are found under /lib folder, they are examples of commands from the API with extra features (search, play/resume etc..)

Use case

The sole purpose is to combine aliases into automated and complex tasks, this can offer a lot of flexibility as shown below:

example 1 (Basic): : Browse Spotify catalog, filter items, feed STDOUT to queue.

example 1

example 2 (Advanced) : Store to a local playlist, shuffle songs, set a timer, transfer ongoing stream to your mobile device.

example 2

example 3 (Expert): : Convert Youtube playlist to a Spotify playlist.

example 1

Notes:

Todo: