Skip to content

Instantly share code, notes, and snippets.

@gate5th
Created September 12, 2018 19:00
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/8b015722c9abe7ecef388a611af3b8f7 to your computer and use it in GitHub Desktop.
Save gate5th/8b015722c9abe7ecef388a611af3b8f7 to your computer and use it in GitHub Desktop.
oldschoolshuffle
export async function byAlbumNoDiscography(state){
//receives this.state from playlistChooser and extract what you need
const {chosenPlaylistId: playlistId, chosenPlaylistName:playlistName} = state;
try {
let tracks = await getSimplePlaylistTracks(playlistId);
const albumIds = identifyAlbumsInPlaylist(tracks);
const playlistObject = convertPlaylistToObjectByProperty(tracks, 'albumId');
let tracksByAlbum = albumIds.map((albumId) => {
return playlistObject[albumId]
});
const sortedByAlbumAndTrack = flatten(tracksByAlbum);
await createPlaylist(sortedByAlbumAndTrack, playlistName, true);
}
catch(err) {
console.error('Error: in byAlbumNoDiscography in spotifyFunctions', err);
console.error(err.stack);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment