Last active
February 19, 2019 02:38
-
-
Save jor3l/98a813a3f99a29548cb6aa4144a418b1 to your computer and use it in GitHub Desktop.
Download Spotify playlist as CSV
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
let arr = Array.from( | |
document.querySelectorAll('.tracklist-row') | |
).map( | |
el => `${el.querySelector('.tracklist-name.ellipsis-one-line').textContent} - ${el.querySelector('.tracklist-row__artist-name-link') && el.querySelector('.tracklist-row__artist-name-link').textContent}` | |
) | |
let csv = "data:text/csv;charset=utf-8,"; | |
arr.forEach(function(row){ | |
csv += `"${row}"\r\n`; | |
}); | |
let encodedUri = encodeURI(csv); | |
let link = document.createElement("a"); | |
link.setAttribute("href", encodedUri); | |
link.setAttribute("download", "my_data.csv"); | |
document.body.appendChild(link); // Required for FF | |
link.click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment