Forked from xavhan/Shazam to youtube and spotify.js
Last active
September 3, 2017 22:29
-
-
Save seungjulee/9efc3f2b966dca43d526 to your computer and use it in GitHub Desktop.
Shazam Crawler and Youtube Searcher in the console
This file contains 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
// 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