Skip to content

Instantly share code, notes, and snippets.

@eblanshey
Last active June 25, 2018 03:37
Show Gist options
  • Save eblanshey/34abba223b1427ec50599f8a272c025e to your computer and use it in GitHub Desktop.
Save eblanshey/34abba223b1427ec50599f8a272c025e to your computer and use it in GitHub Desktop.

Move playlist from google play to spotify

I modified this guy's code to make it work better. Google doesn't render the whole page so only a limited number of songs get added. Instructions (also mostly taken from that guy's post):

  1. Open google chrome -- this will NOT work with Firefox.

  2. Go to https://spotlistr.herokuapp.com/#/search/textbox and log in with Spotify.

  3. Open your Google Play Music playlist in another tab, and stay in that tab.

  4. Open the developer console (click here for a tutorial).

  5. Paste the following code into the console, and press enter. (If the console asks you to "allow pasting", follow the prompts)

function fReplace(thisString, thisThing, thatThing) {
    let tLS = thisString;
    while (tLS.includes(thisThing)) {
        tLS = tLS.replace(thisThing, thatThing);
    }
    return (tLS);
}

function grabAllSongs() {
    var playlist = document.querySelectorAll('.song-table tr.song-row');
    var uniquesFound = 0;
    for (var i = 0; i < playlist.length; i++) {
        var l = playlist[i];
        l.querySelectorAll('td[data-col="title"]')[0].textContent;
        var title = l.querySelectorAll('td[data-col="title"]')[0].textContent;
        title = encodeURI(title);
        title = fReplace(title, "%20%20", "%20");
        title = fReplace(title, "Buy%0A%20", "");
        title = fReplace(title, "%0A%20", "");
        title = fReplace(title, "%0A", "");
        title = decodeURI(title);
        var artist = l.querySelectorAll('td[data-col="artist"]')[0].textContent;
        var album = l.querySelectorAll('td[data-col="album"]')[0].textContent;
        var row = artist + ' | ' + title + ' | ' + album;

        if (allSongs.indexOf(row) === -1) {
            allSongs.push(row);
            uniquesFound++;
        }
    }

    if (uniquesFound > 0) {
        l.scrollIntoView(true);
        window.setTimeout(function () {
            grabAllSongs();
        }, 1000);
    } else {
        finalStr = allSongs.join("\r\n");
        console.log(finalStr);
    }
}

var finalStr;
var topOfPage = document.querySelector('.header-container');
topOfPage.scrollIntoView(true);

var allSongs = [];

window.setTimeout(function () {
    grabAllSongs();
}, 2000);
  1. Wait a bit and a list of songs, artists, and albums will be generated in the console. Note that this will NOT copy any duplicate songs.

  2. Copy the list of songs, artists and albums

  3. Paste the list into the textbox at https://spotlistr.herokuapp.com/#/search/textbox

  4. Press the "Search!" button, and your songs will be loaded up.

  5. Scroll down, choose the songs with multiple matches which you prefer

  6. At the bottom of the page, give your playlist a name, and press the "Create {playlist name}" button.

  7. All done! Whew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment