-
Notifications
You must be signed in to change notification settings - Fork 18
Track API Methods
Tim Case edited this page Jan 5, 2014
·
15 revisions
Get analysis info on tracks given an analysis_url. This method is not part of the Echonest API and is provided as a helper to get track analysis. NOTE: Track analysis url is only valid on Echowrap servers for about 15 minutes after a track is uploaded.
Echowrap.track_analysis(:url =>
'http://echonest-analysis.s3.amazonaws.com/TR/TREYOVK13C9786E66B/3/full.json?
AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1367724668&Signature=vtxZ6YDtsc%2B1ZNOKOsjjbQAhfZM%3D') =>
#<Echowrap::Analysis:0x007fe388b27460 (Analysis returns an immense amount of data which
#is too long to include here, see the Echowrap::Analysis object linked
#below to see what data is returned) Get info about tracks given an id or md5. The md5 parameter is the file md5.
Echowrap.track_profile(:id => 'TRTLKZV12E5AC92E11', :bucket => 'audio_summary') =>
#<Echowrap::Track:0x007fe388b27460 @attrs={:status=>"complete",
:foreign_release_ids=>["7digital-AU:release:1011998", "7digital-MY:release:1011998",
"7digital-UK:release:1011998"], :catalog=>"7digital-AU",
:audio_md5=>"e16bde82eaecd13bde9261b2710aa991", :id=>"TRTLKZV12E5AC92E11",
:song_id=>"SOCRHFJ12A67021D74", :release_image=>
"http://cdn.7static.com/static/img/sleeveart/00/010/119/0001011998_200.jpg",
:artist=>"Weezer", :foreign_ids=>["7digital-AU:track:11123262",
"7digital-MY:track:11123262", "7digital-UK:track:11123262"],
:title=>"El Scorcho", :preview_url=>"http://previews.7digital.com/clips/34/11123262.clip.mp3",
:foreign_release_id=>"7digital-AU:release:1011998", :release=>"Pinkerton - Deluxe Edition",
:foreign_id=>"7digital-AU:track:11123262", :audio_summary=>{:time_signature=>4, :tempo=>74.694,
:energy=>0.66143403908789, :liveness=>0.12703360740225414, :analysis_url=>"http://echonest-
analysis.s3.amazonaws.com/TR/sH3nRgHBizHz2LT0ajgaKomIJNr5FYie3BemYM/3/full.json?
AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1375573408&Signature=2po/cnGffQU21p/7lSMGqCAfngc%3D",
:speechiness=>0.04144175638597536, :acousticness=>0.0013579401106197533, :danceability=>0.5164314670162907,
:key=>1, :duration=>243.64363, :loudness=>-4.613, :valence=>0.1374011453937612, :mode=>1}}>Upload a track to The Echo Nest's analyzer for analysis. The track will be analyzed. This method takes either a url parameter, or a local audio file, which should be the contents of the request body.
#VIA URL:
Echowrap.track_upload(
:url => 'http://freemusicarchive.org/music/download/02086e4b41cd0c8b1c51ccbf6fad58f5507ba8b8') =>
#<Echowrap::Track:0x007f99399f7890 @attrs={:status=>"pending", :artist=>nil, :title=>nil,
:release=>"", :audio_md5=>nil, :bitrate=>nil, :id=>"TRTEWWF140469DAB9F",
:samplerate=>nil, :md5=>"38c273fe98cff0c4fe51165c3f804344"}>
#VIA LOCAL FILE UPLOAD
TRACK_NAME = "DOt_-_05_-_IMF.mp3"
Echowrap.track_upload(:track => File.new(TRACK_NAME), :filetype => 'mp3') =>
#<Echowrap::Track:0x007f824c111a18 @attrs={:status=>"pending",
:song_id=>"SOHWGUB13B0C9CE5A8", :audio_md5=>"2ab7df38867ed2eabe38866334add54e",
:artist=>"DOT", :title=>"IMF", :analyzer_version=>"3.1.4",
:release=>"Calling Home", :artist_id=>"AR4SM3P1187B99977D", :bitrate=>192,
:id=>"TRTEWWF140469DAB9F", :samplerate=>44100, :md5=>"38c273fe98cff0c4fe51165c3f804344"}>