Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save seungjulee/9efc3f2b966dca43d526 to your computer and use it in GitHub Desktop.
Save seungjulee/9efc3f2b966dca43d526 to your computer and use it in GitHub Desktop.
Shazam Crawler and Youtube Searcher in the console
// change this variable to change timeout for async scroll load
var TIMEOUT_IN_MS = 1000
// script from https://gist.github.com/xavhan/87717da0217b9b8299df
// start from www.shazam.com/myshazam
// print all shazam songs loaded on the page
// TODO: Change format to JSON
function printShazamSongs(){
$(".ti__details").each(function(i){
var artist = $(this).find(".ti__artist meta").attr("content");
var title = $(this).find(".ti__title").attr("content");
var format = artist + " - " + title;
var yt = 'http://www.youtube.com/results?search_type=&search_query=' + encodeURI(artist + " " + title) + '&aq=f&oq=';
var spoti = 'https://play.spotify.com/search/'+ encodeURI(artist + " " + title);
var item = new Object;
console.groupCollapsed(format);
console.log(yt);
console.log(spoti);
console.groupEnd();
});
}
// modified script from http://www.alecjacobson.com/weblog/?p=758
// simulate infinite scroll to the bottom to display all songs
function scrollToBottom(){
bottom = document.body.scrollHeight;
current = window.innerHeight + document.body.scrollTop;
if((bottom-current) >0){
window.scrollTo(0, bottom);
setTimeout ( 'scrollToBottom()', TIMEOUT_IN_MS );
}
else{
alert("Done scrolling")
printShazamSongs()
}
}
scrollToBottom();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment