Created
November 13, 2020 13:47
-
-
Save arkon/0409a621acad09ad3f8dc14500af04bb to your computer and use it in GitHub Desktop.
Transfer Google Play Music to Spotify
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
// Cleaned up version of script from https://www.tunemymusic.com/ | |
// to transfer from Google Play Music to Spotify | |
// with the ability to break at some point since | |
// I was going through the entire songs list | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)) | |
} | |
function demo() { | |
if (window.location.href.indexOf('play.google.com') != -1) { | |
list = document.title + "|"; | |
document.getElementsByTagName("h2")[0].scrollIntoView(); | |
demo2(); | |
} | |
} | |
async function demo2() { | |
if (added > 0) { | |
added = 0; | |
var playlist = document.querySelectorAll(".song-table tr.song-row"); | |
for (var i = 0; i < playlist.length; i++) { | |
var l = playlist[i]; | |
title = l.querySelector('td[data-col="title"] .column-content').textContent; | |
img = l.querySelector('td[data-col="title"] .column-content img').src; | |
artist = l.querySelector('td[data-col="artist"] .column-content').textContent; | |
// if (title.toLowerCase().startsWith('z')) { | |
// break; | |
// } | |
if (titles.indexOf(title + artist) == -1) { | |
list = list + img + "***" + artist + "- " + title + "|"; | |
titles.push(title + artist); | |
added++; | |
total++ | |
} | |
} | |
if (added > 0) { | |
playlist[Math.max(Math.round(playlist.length / 2), playlist.length - 5)].scrollIntoView(); | |
await sleep(250); | |
demo2(); | |
return; | |
} | |
} | |
if (total == 0) { | |
alert('Go to the playlist you wish to download and only then click this bookmark.'); | |
return | |
} | |
var form = document.createElement("form"); | |
form.style.visibility = "hidden", form.method = "POST", form.action = "https://www.tunemymusic.com"; | |
var input = document.createElement("input"); | |
input.name = "list", input.value = list, form.appendChild(input), document.body.appendChild(form), form.submit() | |
} | |
added = 1; | |
total = 0; | |
titles = []; | |
demo(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment