Forked from https://github.com/EwanLyon/ncg-spotify
A NodeCG bundle to access the current song playing on Spotify.
-
Clone (or download & extract) to
nodecg/bundles/nodecg-spotify
-
cd nodecg/bundles/nodecg-spotify
and runnpm install --production
-
If nodecg-cli is installed: run
nodecg defaultconfig
else go tonodecg/cfg
and createnodecg-spotify.json
and refer to configschema.json -
Create a Spotify app from https://developer.spotify.com/dashboard/applications
-
Click edit settings and set the redirect URI as
http://localhost:9090/bundles/nodecg-spotify/spotify-callback/index.html
-
Copy the
Client ID
andClient Secret
to the nodecg-spotify cfg innodecg/cfg/nodecg-spotify.json
in the same format asdefaultconfig.json
-
Run the nodecg server:
node index.js
(ornodecg start
if you havenodecg-cli
installed from thenodecg
root directory -
Click log in on the Spotify connector panel
The token should refresh automatically but if something weird happens there is a refresh token button.
nodecg-spotify
creates the Replicant currentSong
.
To access it make a Replicant like const song = nodecg.Replicant('currentSong', 'nodecg-spotify');
name
String - Name of the songartist
String - Name of the artistsalbumArt
String - URL of the album art, local files will not show album artplaying
Boolean - True if the song is currently playing
const songRep = nodecg.Replicant('currentSong', 'nodecg-spotify');
songRep.on('change', (newVal, oldVal) => {
songNameElement.innerHTML = newVal.name;
artistElement.innerHTML = newVal.artist;
albumImageElement.src = newVal.albumArt;
});
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.