Created
April 13, 2022 04:47
-
-
Save Quelklef/fefb042046939fc3bac26ea3ba5d545b to your computer and use it in GitHub Desktop.
Export a Spotify playlist via the web app
This file contains hidden or 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
/* USAGE: Go to Spotify page for playlist, copy+paste into console, scroll */ | |
songs = {}; | |
const songCnt = parseInt(document.querySelector('.ebHsEf.RANLXG3qKB61Bh33I0r2').textContent, 10); | |
console.log(songCnt + ' songs'); | |
id = setInterval(function() { | |
const nodes = Array.from(document.querySelectorAll('.h4HgbO_Uu1JYg5UGANeQ.wTUruPetkKdWAR1dd6w4')); | |
nodes.forEach(node => { | |
node = node.parentNode; | |
const title = node.querySelector('.fCtMzo.t_yrXoUO3qGsJS4Y6iXX').innerText; | |
const artist = node.querySelector('.iCQtmPqY0QvkumAOuCjr .hHrtFe').innerText; | |
const album = node.querySelector('.ebHsEf').innerText; | |
const index = parseInt(node.querySelector('.gAmaez').innerText, 10); | |
if (Number.isFinite(index)) { | |
songs[index] = { title, artist, album }; | |
node.style.transition = 'all 0.75s'; | |
node.style.background = '#0a340a'; | |
node.style.paddingLeft = '1em'; | |
} | |
}); | |
const cntFound = Object.keys(songs).length; | |
console.log(`Found ${cntFound}/${songCnt}`); | |
if (cntFound === songCnt) { | |
clearInterval(id); | |
console.log(Object.keys(songs).sort((a, b) => a - b).map(k => { | |
const song = songs[k]; | |
return `${song.title} ON ${song.album} BY ${song.artist}`; | |
}).join('\n')); | |
} | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wow the green highlighting is a great touch