Skip to content

Instantly share code, notes, and snippets.

@ulybu
Last active January 23, 2017 14:18
Show Gist options
  • Save ulybu/09810641cb1c4e8b80506b9dd18f2474 to your computer and use it in GitHub Desktop.
Save ulybu/09810641cb1c4e8b80506b9dd18f2474 to your computer and use it in GitHub Desktop.
Export googleMusic playlist

#Export a google music playlist

Why

Export to a text list and use anpother tool (like http://www.playlist-converter.net/#/) to import it to another app (like deezer, spotify.. )

How

Currently export to a simple list format, because that's enough to be supported by http://www.playlist-converter.net/#/.

This script will generate from your playlist page a text like this

title artist
hey joe jimmy hendrix
..

Usage

  1. Use chrome
  2. go to your playlist page
  3. Make sur the whole playlist is visible. If not, unzoom the page (like 50%) until the whole playlist fits in the page, doesn't matter if it's not human readeable anymore. The song that aren't visible won't be exported. If the playlist doesn't fit even with the lower zoom then you'll have to scroll and do it over..
  4. Open console ( Ctrl + alt + j on windows, cmd + option + j on mac)
  5. paste the raw content of genPlaylist.js. Hit Enter.
  6. If it works you should have no error and see printed the number of song exported
  7. The result is copied in your clipboard, paste it in a file to save it.
var rowSelector = 'tr.song-row';
var titleSelector = '[data-col="title"] .column-content';
var artistSelector = '[data-col="artist"] .column-content';
var rows = [];
var list = ''
/*
* extract from the page the artist and title and seed the `rows` array
*/
function extractFromHTML () {
var rowNodes = document.querySelectorAll(rowSelector);
var row;
var rowNode
for (rowNode of rowNodes) {
row = {};
var titleNode = rowNode.querySelector(titleSelector);
row.title = titleNode.textContent.trim();
var artistNode = rowNode.querySelector(artistSelector);
row.artist = artistNode.textContent.trim();
rows.push(row);
}
console.log('Found ' + rows.length + ' songs')
}
/*
* Here to simple list (title artiste/n), because the importer I foundnd uses that.
* Format to CSV if needed
*/
function genList () {
list = '';
for (var row of rows) {
list += row.title + ' ' + row.artist + '\n';
}
}
extractFromHTML();
genList();
copy(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment