Last active
May 14, 2020 21:05
-
-
Save spencerwi/be161d032575ef3f4c34684a63511199 to your computer and use it in GitHub Desktop.
Dump GMusic playlist to JSON file
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
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