node-spotify-data
Simple spotify metadata. Supports playlist, cover art, artist, album and track.
Install
npm install spotify-data --save
Parsing URIs
spotify.uri = require('spotify-uri');
- https://github.com/TooTallNate/spotify-uri
var parsed = spotify.uri.parse('spotify:track:1pKYYY0dkg23sQQXi0Q5zN')
// { uri: 'spotify:track:1pKYYY0dkg23sQQXi0Q5zN',
// type: 'track',
// id: '1pKYYY0dkg23sQQXi0Q5zN' }
spotify.uri.formatURI(parsed);
// 'spotify:track:1pKYYY0dkg23sQQXi0Q5zN'
// and more... see https://github.com/TooTallNate/spotify-uri
Available methods
var spotify = ; // All callbacks are called with:var { // ...} // Lookup// spotify.lookup(uri, callback);// // - returns response from spotifys metadata web apispotify;spotify;spotify;spotify; // Lookup alternative:// spotify.<type>(id, callback);// spotify.playlist(user, id, callback);spotify;spotify;spotify;spotify; // Cover:// spotify.cover(uri, [size,] callback);// // - returns url to cover// - available sizes: 60, 85, 120, 300, 640, 'cover'.// defaults to 'cover', which is 300x300, with a spotify logo in lower right corner.// - sizes are also available in `spotify.coverSize`.spotify;spotify;spotify;spotify; // Size examples:spotify;spotify;spotify;spotify; // Cover alternative:// spotify.<type>.cover(id, [size,] callback)// spotify.playlist.cover(user, id, [size,] callback);spotifytrack;spotifyartist;spotifyalbum;spotifyplaylist; // Flatten// spotify.flatten(id, callback);// // - returns array of tracks from any uri or array of uris.spotify;spotify;spotify;spotify; // Flatten alternative:// spotify.<type>.flatten(id, callback);// spotify.playlist.flatten(user, id, callback);spotifytrack;spotifyartist;spotifyalbum;spotifyplaylist; // Flatten list of any URIs:// spotify.flatten(uris, callback);var uris = 'spotify:album:5NCz8TTIiax2h1XTnImAQ2' 'spotify:track:3gGhcHH075qI9CPSXKnxy1' 'spotify:artist:5RBdF1pJSLF3ugc2Y2PoB8' 'spotify:user:syknyk:playlist:0Idyatn0m08Y48tiOovNd9';spotify;
Flatten does not guarantee a list of unique tracks.
E.g.: Using .flatten
on an artist
will return a lot of duplicates, because most albums are released in many different territories (countries) by different labels, and each album have their own listing of tracks.