2

How can I see which playlists a song is included in on Google Play Music? It'd be nice if I could click the three dots when hovering the track and click something like "Included in playlists..." to see a list.

I know I can navigate to a playlist and see the songs included in it. I also know that I can try adding a song to a playlist and it will say if it's a duplicate or not. Neither of these things are what I'm interested in.

Native would be preferable, but a userscript or third party solution would also be acceptable (although I've looked into it and can't think of a way it would be possible, which is why I'm asking here).

0

If you create a text file for your playlist data and also a text file of your song list both in JSON form, you can use the following script to do just this:

Demo

It takes a few seconds to run when there are lots of tracks and playlists.

HTML:

<p>Please note that this will take a few seconds to run if you have a large amount of songs and playlists.</p>
<label>Song text file (generated from <a href="https://webapps.stackexchange.com/q/108103/140514">this answer</a>): <input type="file" id="songInput"></label>
<br>
<label>Playlist text file (generated from <a href="https://webapps.stackexchange.com/a/106604/140514">this answer</a>): <input type="file" id="playlistInput"></label>
<br>
<textarea style="width: 500px; height: 200px;"></textarea>

JS:

var songInput = document.getElementById("songInput"),
    playlistInput = document.getElementById("playlistInput"),
    result = document.querySelector("textarea");

var songList, 
    playlistData;

function loadData(id, elem) {
    if(elem.files
    && elem.files[0]) {
        let myFile = elem.files[0];
        let reader = new FileReader();

        reader.addEventListener('load', function (e) {
            if(id === "songInput")
                songList = JSON.parse(e.target.result);

            if(id === "playlistInput")
                playlistData = e.target.result;

            checkBothAdded();
        });

        reader.readAsBinaryString(myFile);
    }
}

function checkBothAdded() {
    if(songList
    && playlistData) {
        getSongPlaylistData();
    }
}

/* Needed to escape song names that have (), [], etc. */
function regexEscape(s) {
    return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
};

var songData = {};
function getSongPlaylistData() {
    for(let song of songList) {
        let playlistsItsIn = [];

        /* Use regex to search the playlist file for all instances,
           add the playlist name that it's in (if any) to an array. */
        let reg = new RegExp('"([^"]*?)":(?=[^\\]]+' + regexEscape(song) + ')', "g");
        let result;
        while((result = reg.exec(playlistData)) !== null) {
            playlistsItsIn.push(result[1]);
        }

        // Update our song data object
        songData[song] = playlistsItsIn;
    }

    result.value = JSON.stringify(songData, null, '\t');
}

songInput.addEventListener("change", function() {
    loadData("songInput", this);
});

playlistInput.addEventListener("change", function() {
    loadData("playlistInput", this);
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.