-
-
Save dcalacci/7f8853174797c0c56c49 to your computer and use it in GitHub Desktop.
Export your Google Music Library and Playlists (Google Play Music All Access) (see http://webapps.stackexchange.com/questions/50311/print-playlist-from-google-play-music for more)
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
// go to: https://play.google.com/music/listen#/all | |
// and paste this into a Chrome developer console | |
// the songs will be pasted into the clipboard in the order they appear in the list | |
// | |
// originally answered here: http://webapps.stackexchange.com/a/73791/77056 | |
(function(){ | |
var intervalms = 1; //in ms | |
var timeoutms = 3000; //in ms | |
var retries = timeoutms / intervalms; | |
var total = []; | |
var seen = {}; | |
var topId = ""; | |
var interval = setInterval(function(){ | |
var songs = document.querySelectorAll("table.song-table tbody tr.song-row"); | |
if (songs.length > 0) { | |
var currId = songs[0].getAttribute("data-id"); | |
if (currId == topId){ // page has not yet changed | |
retries--; | |
scrollDiv = document.querySelector("div#music-content"); | |
isAtBottom = scrollDiv.scrollTop == (scrollDiv.scrollHeight - scrollDiv.offsetHeight) | |
if (isAtBottom || retries <= 0) { | |
clearInterval(interval); //done | |
copy(total); | |
console.log("Done! " + total.length + " songs copied to clipboard."); | |
} | |
} else { | |
retries = timeoutms / intervalms; | |
topId = currId; | |
// read page | |
for (var i = 0; i < songs.length; i++) { | |
var curr = {name: songs[i].childNodes[0].textContent, | |
length: songs[i].childNodes[1].textContent, | |
artist: songs[i].childNodes[2].textContent, | |
album: songs[i].childNodes[3].textContent, | |
plays: songs[i].childNodes[4].textContent, | |
rating: songs[i].childNodes[5].getAttribute("data-rating"), | |
id: songs[i].getAttribute("data-id") | |
} | |
if (!seen.hasOwnProperty(curr.id)){ // hashset | |
total.push(curr); | |
seen[curr.id] = true; | |
} | |
} | |
songs[songs.length-1].scrollIntoView(true); // go to next page | |
} | |
} | |
}, intervalms); | |
}()); |
Thank you a lot! You made my day!
Try https://musconv.com/ for export of the Google Music across many music platforms.
Actually don't this company spams the world with single-use throw away accounts to push their paid service.
Thanks so much for the script!!! It best solution!!!
Maybe you can replace allsongs[i].{spmething}
on some like that:
getSongAttribute(i,'artist')
var getSongAttribute = function(index, attribute) {
return allsongs[index][attribute].replace('\n','').replace('\r','').trim()
}
Because now there are escape characters and it brokes csv.
Thank you very much!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Getting the following error. How do I fix?
listen.js:1181 Uncaught gx {message: “Error in protected function: copy is not defined”, Osb: true, cause: ReferenceError: copy is not defined
at songsToText (:87:1)
at :130:1
…, stack: “ReferenceError: copy is not defined↵ at songsTo…0d8e628d55fb15f8053919494d29a/listen.js:1180:471)“}