Skip to content

Instantly share code, notes, and snippets.

@sk22
Last active June 3, 2018 14:07
Show Gist options
  • Save sk22/5c493fe64b103c59e6c9c0ddb01c2709 to your computer and use it in GitHub Desktop.
Save sk22/5c493fe64b103c59e6c9c0ddb01c2709 to your computer and use it in GitHub Desktop.
Export Google Play Music playlist
// Copy this into Chrome's debugger console
// This will output all (loaded/visible) songs to the console.
// Format: Title - Artist
// You can use this to port the playlist to another service,
// for example using http://spotlistr.herokuapp.com or http://www.playlist-converter.net
// Warning: Only the visible songs will be in the list,
// so a workaround is to click the "toggle device toolbar" button on the
// upper left of the debugger and set the device height really high (like 5000px), as needed.
// This will force Google Play Music to load all songs visible in the viewport.
// Hint: Wrap the whole script into `copy()` to copy everything to the clipboard.
Array.from(document.querySelectorAll('.song-table tr.song-row'))
.map(song => [
song.querySelector('td[data-col="artist"]').textContent.trim(),
song.querySelector('td[data-col="title"]').textContent.trim()
])
.reduce((pre, song) => `${pre}${song.join(' - ')}\n`, '')
// Include the following line only if you plan importing it to Spotify (which usually uses another format)
.replace(/(?!\s)\&(?=\s)|\(|\)|(?!\s)feat.?(?=\s)|(?!\s)vs.?(?=\s)|original mix/gi, '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment