Skip to content

Instantly share code, notes, and snippets.

@cyrilf
Created April 12, 2013 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyrilf/5368465 to your computer and use it in GitHub Desktop.
Save cyrilf/5368465 to your computer and use it in GitHub Desktop.
Save your We Are Hunted playlist. Download all your We Are Hunted tracks infos in a JSON file.
// Save your We Are Hunted playlist
// Download all your We Are Hunted tracks infos in a JSON file
// by Cyril F (github.com/cyrilf)
// Instructions
//
// Go to wearehunted.com
// Change the USERNAME below by your username or email.
// Copy and paste the following code into your javascript
// console.
// If your using Chrome, press F12, then Escape key
// and paste the code.
// Wait for 2-3 secondes.
// DONE !
// Set your username here
var USERNAME = 'cyrilf';
// Nothing to do below :)
var songs = [];
$('.chart-name').val(USERNAME);
$('.find-btn').click(function() {
setTimeout(getSongsInfos, 2000);
});
$('.find-btn').click();
function getSongsInfos() {
var first = true;
$('.chart-results table tr').each(function() {
if(!first) {
var infos = getInfos($(this));
songs.push(infos);
} else {
first = false;
}
});
generateFile(songs);
}
function getInfos(element) {
var track = element.find('.track').html();
var artist = element.find('.artist').html();
var itunes = element.find('td.source').eq(0).find('a').attr('href') || '';
var spotify = element.find('td.source').eq(1).find('a').attr('href') || '';
var soundcloud = element.find('td.source').eq(2).find('a').attr('href') || '';
return JSON.stringify(
{
itunes: itunes,
spotify: spotify,
soundcloud: soundcloud,
track: track,
artist: artist
},
null, '\t'
);
}
function generateFile(songs) {
uriContent = "data:application/octet-stream," + encodeURIComponent("["+songs+"]");
location.href = uriContent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment