-
Notifications
You must be signed in to change notification settings - Fork 18
Song API Methods
Tim Case edited this page Sep 1, 2013
·
22 revisions
Identifies a song given an Echoprint or Echo Nest Musical Fingerprint hash codes. Note: You can call song/identify with GET or POST see Echonest documentation for details on the differences.
fingerprint = "eJxVlIuNwzAMQ1fxCDL133-xo1rnGqNAEcWy_
ERa2aKeZmW9ustWVYrXrl5bthn_laFkzguNWpk
lEmoTB74JKYZSPlbJ0sy9fQrsrbEaO9W3bsbaW
OoK7IhkHFaf_ag2d75oOQSZczbz5CKA7XgTIBI
XASvFi0A3W8pMUZ7FZTWTVbujCcADlQ_f_WbdR
NJ2vDUwSF0EZmFvAku_CVy440fgiIvArWZZWoJ
7GWd-CVTYC5FCFI8GQdECdROE20UQfLoIUmhLC
7IiByF1gzbAs3tsSKctyC76MPJlHRsZ5qhSQhu
_CJFcKtW4EMrHSIrpTGLFqsdItj1H9JYHQYN7W
2nkC6GDPjZTAzL9dx0fS4M1FoROHh9YhLHWdRc
hQSd_CLTpOHkQQP3xQsA2-sLOUD7CzxU0GmHVd
Ixh46Oide0NrNEmjghG44Ax_k2AoDHsiV6WsiD
6OFm8y-0Lyt8haDBBzeMlAnTuuGYIB4WA2lEPA
WbdeOabgFN6TQMs6ctLA5fHyKMBB0veGrjPfP0
0IAlWNm9n7hEh5PiYYBGKQDP-x4F0CL8HkhoQn
RWN997JyEpnHFR7EhLPQMZmgXS68hsHktEVErr
anvSSR2VwfJhQCnkuwhBUcINNY-xu1pmw3PmBq
U9-8xu0kiF1ngOa8vwBSSzzNw==".gsub("\n", ' ')
Echowrap.song_identify(:code => fingerprint) =>
#<Echowrap::Song:0x007ff1b304b508 @attrs={:score=>54, :title=>"Billie Jean",
#:message=>"OK (match type 5)", :artist_id=>"ARXPPEY1187FB51DF4",
#:artist_name=>"Michael Jackson", :id=>"SODJXOA1313438FB61"}>
query = '{
"metadata": {
"artist": "Michael jackson",
"release": "800 chansons des annes 80",
"title": "Billie jean",
"genre": "",
"bitrate": 192,
"sample_rate": 44100,
"duration": 294,
"filename": "../billie_jean.mp3",
"samples_decoded": 220598,
"given_duration": 20,
"version": 3.13
},
"code": "' + fingerprint + '"}'
Echowrap.song_identify(:query => query) =>
#<Echowrap::Song:0x007f859b99a818 @attrs={:score=>54, :title=>"Billie Jean",
#:message=>"OK (match type 5)", :artist_id=>"ARXPPEY1187FB51DF4",
#:artist_name=>"Michael Jackson", :id=>"SODJXOA1313438FB61"}>
Get info about songs given a list of ids
Echowrap.song_profile(:id=> 'SOCZMFK12AC468668F') =>
#<Echowrap::Song:0x007fa8abbaa490 @attrs={:artist_id=>"ARZHQSP12FE086C216",
:id=>"SOCZMFK12AC468668F", :artist_name=>"Wil-Lean", :title=>"Stay Fly"}>
Search for songs given different query types
Echowrap.song_search(:artist => 'Macklemore', :results => 3) =>
[#<Echowrap::Song:0x007fc8e0a3f560 @attrs={:artist_id=>"AR2XDHU1187B9B484F",
:id=>"SOAFRBZ1312A8A5536", :artist_name=>"Macklemore", :title=>"And We Danced (feat. Ziggy Stardust)"}>,
#<Echowrap::Song:0x007fc8e0a3f538 @attrs={:artist_id=>"AR2XDHU1187B9B484F",
:id=>"SOEPGXT1338A5D83A5", :artist_name=>"Macklemore", :title=>"Can't Hold Us (Feat. Ray Dalton)"}>,
#<Echowrap::Song:0x007fc8e0a3f510 @attrs={:artist_id=>"AR2XDHU1187B9B484F", :id=>"SOCRYSC1313438D0DF",
:artist_name=>"Macklemore", :title=>"The Town"}>]
Echowrap.song_search(:key => 2,
:mode => 0,
:min_energy => 0.35,
:max_energy => 0.65,
:min_danceability => 0.90,
:results => 3,
:sort => 'song_hotttnesss-desc') =>
[#<Echowrap::Song:0x007fa82ab52c08 @attrs={:artist_id=>"ARHFDOW1187B9A6B6D",
:id=>"SOIIWOX13CCFBAB235", :artist_name=>"Late Night Alumni", :title=>"Empty Streets"}>,
#<Echowrap::Song:0x007fa82ab52be0 @attrs={:artist_id=>"AR23C041187FB4D534",
:id=>"SOMTSZB13B366AE759", :artist_name=>"50 Cent", :title=>"Disco Inferno"}>,
#<Echowrap::Song:0x007fa82ab52bb8 @attrs={:artist_id=>"AR8RQVM1187B9A2645",
:id=>"SOBNGDP12A8C13A26D", :artist_name=>"Fujiya & Miyagi", :title=>"UH"}>]
Echowrap.song_search(:artist => 'Macklemore',
:bucket => ['audio_summary', 'artist_location'],
:results => 1) =>
[#<Echowrap::Song:0x007fc8392e1a40 @attrs={:title=>"And We Danced (feat. Ziggy Stardust)",
:artist_name=>"Macklemore", :audio_summary=>{:key=>2, :analysis_url=>"http://echonest-
analysis.s3.amazonaws.com/TR/0pLbjgoRCq6L4-Nnk5wTpFeG6Ouk1NwWMYcKEP/3/full.json?
AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1375508042&Signature=CjFhM1lnr05rmVhcYdxRPR3Nw5Q%3D",
:energy=>0.6722788937963255, :liveness=>0.08902066450149933, :tempo=>125.013,
:speechiness=>0.07387994905866357, :acousticness=>0.07404369808174743, :mode=>0, :time_signature=>4,
:duration=>246.21333, :loudness=>-7.133, :audio_md5=>"928960fb6130be91984ed5197bf1b6cb",
:valence=>0.6466419050880391, :danceability=>0.7551415447533787}, :artist_id=>"AR2XDHU1187B9B484F",
:id=>"SOAFRBZ1312A8A5536", :artist_location=>{:latitude=>47.6036, :location=>"Seattle, WA, US",
:longitude=>-122.329}}>]