-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathSong.php
More file actions
63 lines (58 loc) · 2.01 KB
/
Song.php
File metadata and controls
63 lines (58 loc) · 2.01 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
<?php
/**
* Api calls for getting data about songs.
*
* @link http://developer.echonest.com/docs/v4/song.html
* @author Brent Shaffer <bshafs at gmail dot com>
* @license MIT License
*/
class EchoNest_Api_Song extends EchoNest_Api
{
/**
* Search for songs given different query types
* http://developer.echonest.com/docs/v4/song.html#search
*
* @param array $options see the EchoNest documentation for a list of options
* @return array list of search results
*/
public function search($options)
{
$response = $this->client->get('song/search', $options);
return $this->returnResponse($response, 'songs');
}
/**
* Get info about songs given a list of ids
* http://developer.echonest.com/docs/v4/song.html#profile
*
* @param string|array $id the rosetta ID of the song (can be an array of ids)
* @param string|array $bucket indicates what data should be returned with each artist
* @param bool $limit if true artists will be limited to those that appear in the catalog specified by the id: bucket
* @return array list of search results
*/
public function profile($id, $bucket = null, $limit = false)
{
$response = $this->client->get('song/profile', array(
'id' => $id,
'bucket' => $bucket,
'limit' => $limit,
));
return $this->returnResponse($response, 'songs');
}
/**
* Identifies a song given Echo Nest Musical Fingerpint hash codes.
* http://developer.echonest.com/docs/v4/song.html#indentify
*
* @param array $options see the EchoNest documentation for a list of options
* @return array list of search results
*/
public function identify($options)
{
if (isset($options['query'])) {
$response = $this->client->post('song/identify', $options);
}
else {
$response = $this->client->get('song/identify', $options);
}
return $this->returnResponse($response, 'songs');
}
}