Created
September 12, 2018 19:00
-
-
Save gate5th/8b015722c9abe7ecef388a611af3b8f7 to your computer and use it in GitHub Desktop.
oldschoolshuffle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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