Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <DOCTYPE html>
- <html>
- <head>
- <title>Last FM and Echonest API Tests</title>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
- <style>
- #the_img {display:none;}
- #i_img {display:none;}
- </style>
- </head>
- <body>
- <form>
- <label>Enter an artist</label>
- <input type="text" id="the_artist"></input>
- <input type="submit" id="the_button"></input>
- </form>
- <p>Echonest Hottneess:</p>
- <p id="hot"></p>
- <p id="hot2"></p>
- <p id="hot3"></p>
- <audio id="audio"></audio>
- <script type="text/javascript">
- $(document).ready(function() {
- $("#the_button").click(function() {
- //LAST FM API
- var artist = $("#the_artist").val();
- //ECHONEST API
- var echo_key = "V3WFT6DHG0RJX4UD2";
- var sid = {};
- var echo_base = "http://developer.echonest.com/api/v4/";
- var echo_artist_query = "playlist/dynamic/create?api_key=";
- var echo_artist = artist.split(" ").join("+");
- var echo_url = echo_base + echo_artist_query + echo_key + "&artist=" + echo_artist + "&type=artist-radio&callback=" + escape("?");
- //HOTTTNESSS
- $.getJSON(echo_url,
- function(data) {
- sid = data["response"]["session_id"];
- $("#hot").text(data["response"]["session_id"])
- nexttrack(sid);
- }
- )
- return false;
- })
- });
- function nexttrack(sessionid) {
- var echo_query = "playlist/dynamic/next?api_key=";
- var echo_url2 = echo_base + echo_query + echo_key + "&session_id=" + sessionid + "&format=json";
- $.getJSON(echo_url2,
- function(data) {
- var sid = data["response"]["session_id"];
- $("#hot2").text(data["response"]["session_id"])
- $("#hot3").text(data["response"]["songs"]["title"])
- }
- )
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement