Created
April 12, 2013 01:01
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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