Last active
May 14, 2018 05:13
-
-
Save pll33/81b37f83a804e5ddacdd6adaa0f47a88 to your computer and use it in GitHub Desktop.
Javascript: Spotify playlist information to console log output
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
// output: Artist Name(s) - Track Title - Album Name | |
let trackTitleNodes = document.querySelectorAll('.track-name-wrapper span.tracklist-name'); | |
let artistAlbumNodes = document.querySelectorAll('.track-name-wrapper span.second-line'); | |
// dash-separated playlist | |
let outputText = ``; | |
let artistAlbumSplit = ''; | |
outputText += `Artist - Title - Album\n`; | |
for (let i = 0; i < trackTitleNodes.length; i++) { | |
artistAlbumSplit = artistAlbumNodes[i].innerText.split("•"); | |
outputText += `${artistAlbumSplit[0]} - ${trackTitleNodes[i].innerText} - ${artistAlbumSplit[1]}\n`; | |
} | |
console.log(outputText); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment