<html>
<head>
<title>Show playlists a Google Play song is in</title>
</head>
<body>
<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>
<script type="text/javascript">
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();
}
}
function regexEscape(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
};
var songData = {};
function getSongPlaylistData() {
for(let song of songList) {
let playlistsItsIn = [];
let reg = new RegExp('"([^"]*?)":(?=[^\\]]+' + regexEscape(song) + ')', "g");
let result;
while((result = reg.exec(playlistData)) !== null) {
playlistsItsIn.push(result[1]);
}
songData[song] = playlistsItsIn;
}
result.value = JSON.stringify(songData, null, '\t');
}
songInput.addEventListener("change", function() {
loadData("songInput", this);
});
playlistInput.addEventListener("change", function() {
loadData("playlistInput", this);
});
</script>
</body>
</html>
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |