Skip to content

Instantly share code, notes, and snippets.

@helloitszak
Last active August 29, 2015 14:00
Show Gist options
  • Save helloitszak/11105418 to your computer and use it in GitHub Desktop.
Save helloitszak/11105418 to your computer and use it in GitHub Desktop.
Exports playlists from plug.dj

plug.dj youtube exporter

This not so simple bookmarklet extracts all your youtube links from all your playlists on plug.dj and spits them out in a textarea object in your window.

How do I use

Simply make a new bookmark and set this as the URL, then click it on plug.dj

javascript:(function()%7Brequire(%5B%22f5884%2Fcc643%2Fdb154%22%5D%2Cfunction(e)%7B%24(%22%23export_div%22).remove()%3Bdata%3D%22%22%3Be.read().forEach(function(t)%7Bdata%2B%3D%22Playlist%3A%20%22%2Bt.name%2B%22%5Cn%22%3Bvar%20n%3De.getMedia(t.id)%3Bvar%20r%3Dn.filter(function(e)%7Bif(e.format%3D%3D1)%7Breturn%20true%7D%7D).map(function(e)%7Breturn%20e.cid%7D)%3Br.forEach(function(e)%7Bdata%2B%3D%22http%3A%2F%2Fyoutube.com%2Fwatch%3Fv%3D%22%2Be%2B%22%5Cn%22%7D)%3Bdata%2B%3D%22%5Cn%5Cn%5Cn%22%7D)%3Bleft%3D0%3Bvar%20t%3D%24(%22%3Cdiv%20%2F%3E%22).attr(%22id%22%2C%22export_div%22).css(%22background-color%22%2C%22white%22).css(%22border%22%2C%22solid%201px%20black%22).css(%22position%22%2C%22absolute%22).css(%22top%22%2C0).css(%22left%22%2C0).css(%22width%22%2C%22100%25%22).css(%22height%22%2C%22100%25%22).css(%22z-index%22%2C100)%3Bvar%20n%3D%24(%22%3Ctextarea%20rows%3D%2750%27%20cols%3D%27100%27%20%2F%3E%22)%3Bn.val(data)%3Bvar%20r%3D%24(%22%3Cbutton%3EClose%3C%2Fbutton%3E%22)%3Br.click(function()%7Bt.remove()%7D)%3Bt.append(r)%3Bt.append(%22%3Cbr%20%2F%3E%22)%3Bt.append(n)%3B%24(%22body%22).append(t)%7D)%7D)()

Disclaimer

This could break at any time, it's injecting into one of p.dj's require.js functions which is an obfuscated name. I don't know how this might change between code releases. If it's not working, you could always ping me on Twitter and I could pretty easily fix it.

(function () {
require(["ba783/e9c92/ebb42"], function(playlistapi){
$('#export_div').remove();
data = "";
playlistapi.read().forEach(function (playlist) {
data += "Playlist: " + playlist.name + "\n";
var playlist_data = playlistapi.getMedia(playlist.id);
var ids = playlist_data.filter(function (item) {
if (item.format == 1) {
return true;
}
}).map(function (item) {
return item.cid;
});
ids.forEach(function(item) {
data += "http://youtube.com/watch?v=" + item + "\n";
});
data += "\n\n\n";
});
left = 0;
var box = $("<div />")
.attr("id", "export_div")
.css("background-color", "white")
.css("border", "solid 1px black")
.css("position", "absolute")
.css("top", 0)
.css("left", 0)
.css("width", "100%")
.css("height", "100%")
.css("z-index", 100);
var text = $("<textarea rows='50' cols='100' />");
text.val(data);
var button = $("<button>Close</button>");
button.click(function() {
box.remove();
});
box.append(button);
box.append("<br />");
box.append(text);
$("body").append(box);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment