Skip to content

Instantly share code, notes, and snippets.

@gate5th
Created September 12, 2018 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gate5th/efdf0a490fca3adfce96479c69bcefe6 to your computer and use it in GitHub Desktop.
Save gate5th/efdf0a490fca3adfce96479c69bcefe6 to your computer and use it in GitHub Desktop.
oldschoolshuffle
async function identifyAlbumsByArtistId(artistId, returnSimpleArray=true) {
//returns an array of albumIds that appear in the playlist, without duplicates
const arrayOfAlbumObjects = await spotifyApi.getArtistAlbums(artistId)
let albumIds = arrayOfAlbumObjects.items.map((albumObj) => {
if (returnSimpleArray) {
return albumObj.id
} else {
return ({albumId: albumObj.id, albumName: albumObj.name, albumUri: albumObj.uri})
}
})
albumIds = uniq(albumIds);
albumIds = shuffleArray(albumIds);
return albumIds;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment