Skip to content

Instantly share code, notes, and snippets.

@spencerwi
Last active May 14, 2020 21:05
Show Gist options
  • Save spencerwi/be161d032575ef3f4c34684a63511199 to your computer and use it in GitHub Desktop.
Save spencerwi/be161d032575ef3f4c34684a63511199 to your computer and use it in GitHub Desktop.
Dump GMusic playlist to JSON file
function readRow(songRowTr) {
let title = songRowTr.querySelector("td[data-col='title']").innerText;
let artist = songRowTr.querySelector("td[data-col='artist']").innerText;
let album = songRowTr.querySelector("td[data-col='album']").innerText;
return {title, artist, album}
}
function dumpPlaylist() {
let playlistName = document.querySelector('gpm-detail-page-header').querySelector('h2[slot=title]').innerText;
let tracks = Array.from(document.querySelectorAll('tr.song-row')).map(songRowTr => readRow(songRowTr));
return {name: playlistName, tracks}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment