-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.html
More file actions
188 lines (136 loc) · 7.33 KB
/
examples.html
File metadata and controls
188 lines (136 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE HTML>
<html>
<head>
<title>EchoNest JavaScript API</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js" type="text/javascript"></script>
<script src="js/jquery.echonest.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var echonest = new EchoNest("KTY7T5L87IZ1OG2TM");
// get a set of "Hybrid" audio and output as HTML5 audio tags to the page
echonest.artist("Hybrid").audio( function(audioCollection) {
$("#artistAudio").append( audioCollection.to_html('<p>${artist} - ${length} long<br /><audio src="${url}" controls preload="none"></audio></p>') );
});
// get a single audio url
echonest.artist("Prince").audio( function(audioCollection) {
$('#artistAudioURL').append(audioCollection.data.audio[0].url);
});
// get the second Radiohead biography by artist id and output it onto the page, also output the site it came from and the license used. Nested items are available through a prefix. E.g. "license_type"
echonest.artist("ARH6W4X1187B99274F").biographies( function(biographyCollection) {
$("#artistBiography").append( biographyCollection.at(1).to_html('<p>${text} <br/>by: <strong>${site} - <span class="license">${license_type}</span></strong></p>') );
});
// get a summary of the booka shade blogs plus a count of the available items on the server, where we started from and how many items in our local collection.
echonest.artist("Booka Shade").blogs( function(blogCollection) {
$("#artistBlogs").append( blogCollection.to_html('<p>${summary}<br/><span class="total">Total: </span> | <span class="started_at">Started At: </span> | <span class="size">Size of Collection: </span></p>') );
$("#artistBlogs .total").append( blogCollection.total() );
$("#artistBlogs .started_at").append( blogCollection.start() );
$("#artistBlogs .size").append( blogCollection.size() );
});
// how well do people know Trentemøller?
echonest.artist("Trentemøller").familiarity( function(familiarity) {
$('#artistFamiliarity').append( familiarity.to_html('<p>"${familiarity}"</p>') );
});
// how hot are The Glitch Mob?
echonest.artist("The Glitch Mob").hotttnesss( function(hotttnesss) {
$('#artistHotttnesss').append( hotttnesss.to_html('<p>"${hotttnesss}"</p>') );
});
// get a set of "Radiohead" artist images and output as a bunch of images to the page (limited to first five results)
echonest.artist("Radiohead").images( function(imageCollection) {
$('#artistImages').append( imageCollection.to_html('<img src="${url}">') );
}, {results: 5});
// catching up with Depeche Mode (a.k.a what's news)
echonest.artist("Depeche Mode").news( function(newsCollection) {
$('#artistNews').append( newsCollection.to_html('<p>${summary}<br/><strong>Posted on:</strong> ${date_posted}</p>') );
});
// get a profile on The Cure, including artist id and foreign catalog id
echonest.artist("The Cure").profile( function(profile) {
$('#artistProfile').append( profile.to_html('<dl><dt>Artist Id</dt><dd>${id}</dd><dt>Foreign Catalog Id</dt><dd>${foreign_ids_catalog}</dd></dl>') );
});
// get reviews about Radiohead
echonest.artist("Radiohead").reviews( function(reviewCollection) {
$('#artistReviews').append( reviewCollection.to_html('<p>${summary}</p>') );
});
// perform an artist search using a search options hash
searchOptions = {
name: 'The',
fuzzy_match: true,
bucket: 'id:7digital'
};
echonest.artist().search( function(searchResultsCollection) {
$('#artistSearchResults').append( searchResultsCollection.to_html('${name} - <strong>${foreign_ids_0_foreign_id}</strong><br/>') );
}, searchOptions);
// what songs did Depeche Mode write?
echonest.artist("Depeche Mode").songs( function(songsCollection) {
$('#artistSongs').append( songsCollection.to_html('${id} - ${title}<br/>') );
});
// which artists are similar to Muse?
echonest.artist("Muse").similar( function(similarCollection) {
$('#artistSimilar').append( similarCollection.to_html('${name} - ${id}<br/>') );
});
// what terms are used to descript the artist David Bowie?
echonest.artist("David Bowie").terms( function(termsCollection) {
$('#artistTerms').append( termsCollection.to_html('<strong>${name}</strong> - ${frequency}<br/>') );
});
// what artists are currently "hottt"? (this should return a hotttnesss value but doesn't)
echonest.artist().top_hottt( function(topHotttCollection) {
$('#artistTopHottt').append( topHotttCollection.to_html('<strong>${name}</strong> - ${hotttnesss}<br/>') );
});
// what artists are currently "hottt"? (this should return a hotttnesss value but doesn't)
echonest.artist().top_terms( function(topTermsCollection) {
$('#artistTopTerms').append( topTermsCollection.to_html('<strong>${name}</strong> - ${frequency}<br/>') );
});
// give me the amazon.com link for Pink Floyd
echonest.artist("Pink Floyd").urls( function(urlsCollection) {
$('#artistUrls').append( urlsCollection.to_html('<a href="${amazon_url}">${amazon_url}</a>') );
});
// give me videos featuring Calexico
echonest.artist("Calexico").video( function(videoCollection) {
$('#artistVideos').append( videoCollection.to_html('${title} (${site} : ${url})<br/>') );
});
});
</script>
</head>
<body>
<h1>EchoNest JavaScript API Examples</h1>
<p>A set of examples for interacting with the EchoNest API</p>
<h2>Artist Endpoint</h2>
<h3>Audio of "Hybrid"</h3>
<div id="artistAudio"></div>
<h3>URL to a Prince Song</h3>
<div id="artistAudioURL"></div>
<h3>Biography of "Radiohead"</h3>
<div id="artistBiography"></div>
<h3>Blog Posts About "Booka Shade"</h3>
<div id="artistBlogs"></div>
<h3>Peoples Familiarity of "Trentemøller"</h3>
<div id="artistFamiliarity"></div>
<h3>"The Glitch Mob" Hotttnesss</h3>
<div id="artistHotttnesss"></div>
<h3>Images of "Radiohead"</h3>
<div id="artistImages"></div>
<h3>News about "Depeche Mode"</h3>
<div id="artistNews"></div>
<h3>Profile of "The Cure"</h3>
<div id="artistProfile"></div>
<h3>Reviews of "Radiohead"</h3>
<div id="artistReviews"></div>
<h3>Search Results for "The"</h3>
<div id="artistSearchResults"></div>
<h3>Songs by "Depeche Mode"</h3>
<div id="artistSongs"></div>
<h3>Artists Similar to "Muse"</h3>
<div id="artistSimilar"></div>
<h3>Terms Used to Describe "David Bowie"</h3>
<div id="artistTerms"></div>
<h3>Current Top Hottt Artists</h3>
<div id="artistTopHottt"></div>
<h3>Current Top Terms</h3>
<div id="artistTopTerms"></div>
<h3>Amazon URL for "Pink Floyd"</h3>
<div id="artistUrls"></div>
<h3>Videos for "Calexico"</h3>
<div id="artistVideos"></div>
</body>
</html>