spotify-player
This is a JavaScript API that drives Spotify in a Chrome window.
You need to have Chrome installed. And it can't run headless, so on Linux, you need an x window server. You can use xvfb if you don't have a graphics card or are in a container.
Usage
You need the following environment variable(s) set:
CHROME_PATH="path to your chrome executable"
Then:
const spotify = require("@suchipi/spotify-player");
spotify.login(username, password);
spotify.searchAndPlay("c418");
spotify.playURL("https://open.spotify.com/playlist/1L3GAiiBL5sBNbDEAMGMEA");
spotify.play();
spotify.pause();
spotify.previous();
spotify.next();
spotify.startRadio();
const infoString = await spotify.nowPlayingInfo();
Example REPL
Given a .env
file in the current working directory with the following environment variables defined:
SPOTIFY_USERNAME="your spotify username or email"
SPOTIFY_PASSWORD="your spotify password"
CHROME_PATH="path to your chrome executable"
You can run node -r @suchipi/spotify-player/repl -e ''
to load a sample song and open a repl where you can test other commands.
License
MIT