echowrap 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.travis.yml +16 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +111 -0
- data/Rakefile +1 -0
- data/echowrap.gemspec +24 -0
- data/lib/echowrap/analysis.rb +39 -0
- data/lib/echowrap/api/artist.rb +387 -0
- data/lib/echowrap/api/oauth.rb +25 -0
- data/lib/echowrap/api/playlist.rb +248 -0
- data/lib/echowrap/api/sandbox.rb +45 -0
- data/lib/echowrap/api/song.rb +111 -0
- data/lib/echowrap/api/taste_profile.rb +296 -0
- data/lib/echowrap/api/track.rb +64 -0
- data/lib/echowrap/api/utils.rb +57 -0
- data/lib/echowrap/artist.rb +73 -0
- data/lib/echowrap/asset.rb +12 -0
- data/lib/echowrap/audio_summary.rb +15 -0
- data/lib/echowrap/base.rb +88 -0
- data/lib/echowrap/biography.rb +13 -0
- data/lib/echowrap/blog.rb +8 -0
- data/lib/echowrap/call_list.rb +8 -0
- data/lib/echowrap/category_map.rb +8 -0
- data/lib/echowrap/client.rb +80 -0
- data/lib/echowrap/configurable.rb +84 -0
- data/lib/echowrap/default.rb +88 -0
- data/lib/echowrap/doc_counts.rb +8 -0
- data/lib/echowrap/echonest_id.rb +8 -0
- data/lib/echowrap/error/bad_gateway.rb +11 -0
- data/lib/echowrap/error/bad_request.rb +10 -0
- data/lib/echowrap/error/client_error.rb +35 -0
- data/lib/echowrap/error/configuration_error.rb +8 -0
- data/lib/echowrap/error/forbidden.rb +10 -0
- data/lib/echowrap/error/gateway_timeout.rb +11 -0
- data/lib/echowrap/error/internal_server_error.rb +11 -0
- data/lib/echowrap/error/not_acceptable.rb +10 -0
- data/lib/echowrap/error/not_found.rb +10 -0
- data/lib/echowrap/error/server_error.rb +28 -0
- data/lib/echowrap/error/service_unavailable.rb +11 -0
- data/lib/echowrap/error/too_many_requests.rb +12 -0
- data/lib/echowrap/error/unauthorized.rb +10 -0
- data/lib/echowrap/error/unprocessable_entity.rb +10 -0
- data/lib/echowrap/error.rb +32 -0
- data/lib/echowrap/familiarity.rb +8 -0
- data/lib/echowrap/feed.rb +14 -0
- data/lib/echowrap/foreign_id.rb +10 -0
- data/lib/echowrap/genre.rb +8 -0
- data/lib/echowrap/hotttnesss.rb +8 -0
- data/lib/echowrap/image.rb +15 -0
- data/lib/echowrap/item.rb +95 -0
- data/lib/echowrap/item_request.rb +8 -0
- data/lib/echowrap/keyvalues.rb +8 -0
- data/lib/echowrap/license.rb +10 -0
- data/lib/echowrap/location.rb +8 -0
- data/lib/echowrap/meta.rb +9 -0
- data/lib/echowrap/news_article.rb +8 -0
- data/lib/echowrap/options.rb +10 -0
- data/lib/echowrap/playlist.rb +47 -0
- data/lib/echowrap/prediction.rb +7 -0
- data/lib/echowrap/rate_limit.rb +47 -0
- data/lib/echowrap/reference.rb +8 -0
- data/lib/echowrap/request/multipart_with_file.rb +36 -0
- data/lib/echowrap/response/parse_json.rb +25 -0
- data/lib/echowrap/response/raise_error.rb +31 -0
- data/lib/echowrap/review.rb +8 -0
- data/lib/echowrap/rule.rb +8 -0
- data/lib/echowrap/sandbox.rb +11 -0
- data/lib/echowrap/seeds.rb +9 -0
- data/lib/echowrap/sequenced_data/bar.rb +4 -0
- data/lib/echowrap/sequenced_data/beat.rb +4 -0
- data/lib/echowrap/sequenced_data/section.rb +6 -0
- data/lib/echowrap/sequenced_data/segment.rb +4 -0
- data/lib/echowrap/sequenced_data/tatum.rb +4 -0
- data/lib/echowrap/sequenced_data.rb +12 -0
- data/lib/echowrap/song.rb +24 -0
- data/lib/echowrap/status.rb +12 -0
- data/lib/echowrap/taste_profile.rb +28 -0
- data/lib/echowrap/term.rb +8 -0
- data/lib/echowrap/track.rb +21 -0
- data/lib/echowrap/update_info.rb +8 -0
- data/lib/echowrap/urls.rb +9 -0
- data/lib/echowrap/version.rb +18 -0
- data/lib/echowrap/video.rb +7 -0
- data/lib/echowrap/years_active.rb +8 -0
- data/lib/echowrap.rb +78 -0
- data/spec/echonest/api/artist_spec.rb +901 -0
- data/spec/echonest/api/oauth_spec.rb +29 -0
- data/spec/echonest/api/playlist_spec.rb +274 -0
- data/spec/echonest/api/sandbox_spec.rb +67 -0
- data/spec/echonest/api/song_spec.rb +326 -0
- data/spec/echonest/api/taste_profile_spec.rb +403 -0
- data/spec/echonest/api/track_spec.rb +167 -0
- data/spec/echonest/base_spec.rb +119 -0
- data/spec/echonest/client_spec.rb +174 -0
- data/spec/echonest/error_spec.rb +20 -0
- data/spec/echonest/rate_limit_spec.rb +76 -0
- data/spec/echonest_spec.rb +65 -0
- data/spec/fixtures/artist/biographies.json +1 -0
- data/spec/fixtures/artist/blogs.json +1 -0
- data/spec/fixtures/artist/extract.json +1 -0
- data/spec/fixtures/artist/familiarity.json +1 -0
- data/spec/fixtures/artist/hotttnesss.json +1 -0
- data/spec/fixtures/artist/images.json +1 -0
- data/spec/fixtures/artist/list_genres.json +1 -0
- data/spec/fixtures/artist/list_terms.json +1 -0
- data/spec/fixtures/artist/news.json +1 -0
- data/spec/fixtures/artist/profile.json +1 -0
- data/spec/fixtures/artist/reviews.json +1 -0
- data/spec/fixtures/artist/search.json +1 -0
- data/spec/fixtures/artist/similar.json +1 -0
- data/spec/fixtures/artist/songs.json +1 -0
- data/spec/fixtures/artist/suggest.json +1 -0
- data/spec/fixtures/artist/terms.json +1 -0
- data/spec/fixtures/artist/top_hottt.json +1 -0
- data/spec/fixtures/artist/top_terms.json +1 -0
- data/spec/fixtures/artist/twitter.json +1 -0
- data/spec/fixtures/artist/urls.json +1 -0
- data/spec/fixtures/artist/video.json +1 -0
- data/spec/fixtures/billie_jean_fingerprint.txt +1 -0
- data/spec/fixtures/billie_jean_query.json +16 -0
- data/spec/fixtures/oauth/timestamp.json +1 -0
- data/spec/fixtures/playlist/basic.json +1 -0
- data/spec/fixtures/playlist/dynamic/create.json +1 -0
- data/spec/fixtures/playlist/dynamic/delete.json +1 -0
- data/spec/fixtures/playlist/dynamic/feedback.json +1 -0
- data/spec/fixtures/playlist/dynamic/info.json +1 -0
- data/spec/fixtures/playlist/dynamic/next.json +1 -0
- data/spec/fixtures/playlist/dynamic/restart.json +1 -0
- data/spec/fixtures/playlist/dynamic/steer.json +1 -0
- data/spec/fixtures/playlist/static.json +1 -0
- data/spec/fixtures/sandbox/access.json +19 -0
- data/spec/fixtures/sandbox/list.json +1 -0
- data/spec/fixtures/song/identify.json +19 -0
- data/spec/fixtures/song/profile.json +1 -0
- data/spec/fixtures/song/search.json +1 -0
- data/spec/fixtures/taste_profile/ban.json +9 -0
- data/spec/fixtures/taste_profile/create.json +1 -0
- data/spec/fixtures/taste_profile/delete.json +11 -0
- data/spec/fixtures/taste_profile/favorite.json +9 -0
- data/spec/fixtures/taste_profile/feed.json +1 -0
- data/spec/fixtures/taste_profile/keyvalues.json +4 -0
- data/spec/fixtures/taste_profile/list.json +1 -0
- data/spec/fixtures/taste_profile/play.json +9 -0
- data/spec/fixtures/taste_profile/predict.json +1 -0
- data/spec/fixtures/taste_profile/profile.json +1 -0
- data/spec/fixtures/taste_profile/rate.json +9 -0
- data/spec/fixtures/taste_profile/read.json +1 -0
- data/spec/fixtures/taste_profile/similar.json +14 -0
- data/spec/fixtures/taste_profile/skip.json +9 -0
- data/spec/fixtures/taste_profile/status.json +2 -0
- data/spec/fixtures/taste_profile/update.json +10 -0
- data/spec/fixtures/taste_profile/update_request_data.json +4 -0
- data/spec/fixtures/technolol-music.mp3 +0 -0
- data/spec/fixtures/track/analysis.json +3 -0
- data/spec/fixtures/track/profile.json +35 -0
- data/spec/fixtures/track/upload.json +21 -0
- data/spec/helper.rb +50 -0
- metadata +323 -0
@@ -0,0 +1,296 @@
|
|
1
|
+
require 'echowrap/api/utils'
|
2
|
+
|
3
|
+
module Echowrap
|
4
|
+
module API
|
5
|
+
module TasteProfile
|
6
|
+
include Echowrap::API::Utils
|
7
|
+
|
8
|
+
# Creates a taste profile.
|
9
|
+
#
|
10
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#create
|
11
|
+
# @authentication Requires api key
|
12
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
13
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
14
|
+
# @return [Echowrap::TasteProfile] The taste profile.
|
15
|
+
# @param options [Hash] A customizable set of options.
|
16
|
+
# @option options [String] :name The name of the taste profile. Required. Example: 'Favorite artists of Paul'.
|
17
|
+
# @option options [String] :type The type of the taste profile. Required, must be one of ['artist', 'song', 'general']. Example: 'song'
|
18
|
+
#
|
19
|
+
# @example taste_profile_create
|
20
|
+
# Echowrap.taste_profile_create(:name => "Favorite artists of Paul", :type => 'artist')
|
21
|
+
def taste_profile_create(options={})
|
22
|
+
object_from_response(Echowrap::TasteProfile, :post, '/api/v4/catalog/create', nil, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Updates (adds or deletes) items from a taste profile. The body of the post should include an item block that describes modifications to the taste profile.
|
26
|
+
#
|
27
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#update
|
28
|
+
# @authentication Requires api key
|
29
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
30
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
31
|
+
# @return [Echowrap::TasteProfile] The taste profile.
|
32
|
+
# @param options [Hash] A customizable set of options.
|
33
|
+
# @option options [String] :id The ID of the taste profile. Required. Example: 'CANVFPJ131839D8144'
|
34
|
+
# @option options [String] :data The data to be uploaded. Required, Must be JSON format. See Echowrap API docs for data options
|
35
|
+
#
|
36
|
+
# @example taste_profile_update
|
37
|
+
# Echowrap.taste_profile_update(:name => "Favorite artists of Paul", :type => 'artist')
|
38
|
+
def taste_profile_update(options={})
|
39
|
+
object_from_response(Echowrap::TasteProfile,
|
40
|
+
:post,
|
41
|
+
'/api/v4/catalog/update',
|
42
|
+
nil,
|
43
|
+
options.merge({:data_type => 'json'}))
|
44
|
+
end
|
45
|
+
|
46
|
+
# Retrieve the catalog-level key/values that are stored in the Taste Profile
|
47
|
+
#
|
48
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#keyvalues
|
49
|
+
# @authentication Requires api key
|
50
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
51
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
52
|
+
# @return [Echowrap::TasteProfile] The taste profile.
|
53
|
+
# @param options [Hash] A customizable set of options.
|
54
|
+
# @option options [String] :id The ID of the taste profile. Required. Example: 'CANVFPJ131839D8144'
|
55
|
+
#
|
56
|
+
# @example taste_profile_keyvalues
|
57
|
+
# Echowrap.taste_profile_keyvalues(:id => 'CANVFPJ131839D8144')
|
58
|
+
def taste_profile_keyvalues(options={})
|
59
|
+
object_from_response(Echowrap::TasteProfile, :get, '/api/v4/catalog/keyvalues', nil, options)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Increment the playcount for the given items by the given count.
|
63
|
+
#
|
64
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#play
|
65
|
+
# @authentication Requires api key
|
66
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
67
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
68
|
+
# @return [Boolean] Message success.
|
69
|
+
# @param options [Hash] A customizable set of options.
|
70
|
+
# @option options [String] :id The ID of the taste profile. Required. Example: 'CANVFPJ131839D8144'
|
71
|
+
# @option options [String] :item The id of the item(s) in the taste profile to be updated. This can be the simple item ID or the Rosetta ID of the item. The items must already be in the taste profile. Examples: 'kfw', 'ARK3D5J1187B9BA0B8', 'CAOFUDS12BB066268E:artist:kfw', '7digital-US:track:293030'
|
72
|
+
# @option options [Integer] :plays Increments the play count for the specified item(s) by the given value. Not required, defaults to 1, must be between 1 and 100.
|
73
|
+
#
|
74
|
+
# @example taste_profile_play
|
75
|
+
# Echowrap.taste_profile_play(:id => 'CANVFPJ131839D8144', :item => 'kfw')
|
76
|
+
def taste_profile_play(options={})
|
77
|
+
boolean_from_response(:get, '/api/v4/catalog/play', options)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Increment the skip count for the given items by the given count
|
81
|
+
#
|
82
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#skip
|
83
|
+
# @authentication Requires api key
|
84
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
85
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
86
|
+
# @return [Boolean] Message success
|
87
|
+
# @param options [Hash] A customizable set of options.
|
88
|
+
# @option options [String] :id The ID of the taste profile. Required. Example: 'CANVFPJ131839D8144'
|
89
|
+
# @option options [String] :item The id of the item(s) in the taste profile to be updated. This can be the simple item ID or the Rosetta ID of the item. The items must already be in the taste profile. Examples: 'kfw', 'ARK3D5J1187B9BA0B8', 'CAOFUDS12BB066268E:artist:kfw', '7digital-US:track:293030'
|
90
|
+
# @option options [Integer] :skips Increments the skip count for the specified item(s) by the given value. Not required, defaults to 1, must be between 1 and 100.
|
91
|
+
#
|
92
|
+
# @example taste_profile_skip
|
93
|
+
# Echowrap.taste_profile_skip(:id => 'CANVFPJ131839D8144', :item => 'kfw')
|
94
|
+
def taste_profile_skip(options={})
|
95
|
+
boolean_from_response(:get, '/api/v4/catalog/skip', options)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Indicates that the given items have been banned or unbanned.
|
99
|
+
#
|
100
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#ban
|
101
|
+
# @authentication Requires api key
|
102
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
103
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
104
|
+
# @return [Boolean] Message success
|
105
|
+
# @param options [Hash] A customizable set of options.
|
106
|
+
# @option options [String] :id The ID of the taste profile. Required. Example: 'CANVFPJ131839D8144'
|
107
|
+
# @option options [String] :item The id of the item(s) in the taste profile to be updated. This can be the simple item ID or the Rosetta ID of the item. The items must already be in the taste profile. Examples: 'kfw', 'ARK3D5J1187B9BA0B8', 'CAOFUDS12BB066268E:artist:kfw', '7digital-US:track:293030'
|
108
|
+
# @option options [Integer] :ban Sets the ban flag of the specified items(s) to the given value. Not required, defaults to 'true', must be one of ['true', 'false'].
|
109
|
+
#
|
110
|
+
# @example taste_profile_ban
|
111
|
+
# Echowrap.taste_profile_ban(:id => 'CANVFPJ131839D8144', :item => 'kfw')
|
112
|
+
def taste_profile_ban(options={})
|
113
|
+
boolean_from_response(:get, '/api/v4/catalog/ban', options)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Indicates that the given items have been favorited or unfavorited.
|
117
|
+
#
|
118
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#favorite
|
119
|
+
# @authentication Requires api key
|
120
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
121
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
122
|
+
# @return [Boolean] Message success.
|
123
|
+
# @param options [Hash] A customizable set of options.
|
124
|
+
# @option options [String] :id The ID of the taste profile. Required. Example: 'CANVFPJ131839D8144'
|
125
|
+
# @option options [String] :item The id of the item(s) in the taste profile to be updated. This can be the simple item ID or the Rosetta ID of the item. The items must already be in the taste profile. Examples: 'kfw', 'ARK3D5J1187B9BA0B8', 'CAOFUDS12BB066268E:artist:kfw', '7digital-US:track:293030'
|
126
|
+
# @option options [String] :favorite Sets the favorite flag of the specified items(s) to the given value. Not required, defaults to 'true', must be either ['true, 'false'].
|
127
|
+
#
|
128
|
+
# @example taste_profile_favorite
|
129
|
+
# Echowrap.taste_profile_favorite(:id => 'CANVFPJ131839D8144', :item => 'kfw')
|
130
|
+
def taste_profile_favorite(options={})
|
131
|
+
boolean_from_response(:get, '/api/v4/catalog/favorite', options)
|
132
|
+
end
|
133
|
+
|
134
|
+
# Apply the given rating to the given items
|
135
|
+
#
|
136
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#rate
|
137
|
+
# @authentication Requires api key
|
138
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
139
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
140
|
+
# @return [Boolean] Message success.
|
141
|
+
# @param options [Hash] A customizable set of options.
|
142
|
+
# @option options [String] :id The ID of the taste profile. Required. Example: 'CANVFPJ131839D8144'
|
143
|
+
# @option options [String] :item The id of the item(s) in the taste profile to be updated. This can be the simple item ID or the Rosetta ID of the item. The items must already be in the taste profile. Examples: 'kfw', 'ARK3D5J1187B9BA0B8', 'CAOFUDS12BB066268E:artist:kfw', '7digital-US:track:293030'
|
144
|
+
# @option options [Integer] :rating Sets the rating of the specified items(s) to the given value. Not required, defaults to 5, must be between 1 and 10.
|
145
|
+
#
|
146
|
+
# @example taste_profile_rate
|
147
|
+
# Echowrap.taste_profile_rate(:id => 'CANVFPJ131839D8144', :item => 'kfw')
|
148
|
+
def taste_profile_rate(options={})
|
149
|
+
boolean_from_response(:get, '/api/v4/catalog/rate', options)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns a list of all taste profiles created on this key
|
153
|
+
#
|
154
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#list
|
155
|
+
# @authentication Requires api key
|
156
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
157
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
158
|
+
# @return [Array] Array of taste profiles.
|
159
|
+
# @param options [Hash] A customizable set of options.
|
160
|
+
# @option options [Integer] :results The number of results desired.
|
161
|
+
# @option options [Integer] :start The desired index of the first result returned.
|
162
|
+
#
|
163
|
+
# @example taste_profile_list
|
164
|
+
# Echowrap.taste_profile_list
|
165
|
+
def taste_profile_list(options={})
|
166
|
+
objects_from_response(Echowrap::TasteProfile, :get, '/api/v4/catalog/list', :catalogs, options)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Deletes the entire taste profile. Only the API key used to create a taste profile can be used to delete that taste profile.
|
170
|
+
#
|
171
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#delete
|
172
|
+
# @authentication Requires api key
|
173
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
174
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
175
|
+
# @return [Echowrap::TasteProfile] The taste profiles.
|
176
|
+
# @param options [Hash] A customizable set of options.
|
177
|
+
# @option options [String] :id The ID of the taste profile. Required. Example: 'CANVFPJ131839D8144'
|
178
|
+
#
|
179
|
+
# @example taste_profile_delete
|
180
|
+
# Echowrap.taste_profile_delete
|
181
|
+
def taste_profile_delete(options={})
|
182
|
+
object_from_response(Echowrap::TasteProfile, :post, '/api/v4/catalog/delete', nil, options)
|
183
|
+
end
|
184
|
+
|
185
|
+
# Get basic information on a taste profile
|
186
|
+
#
|
187
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#profile
|
188
|
+
# @authentication Requires api key
|
189
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
190
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
191
|
+
# @return [Echowrap::TasteProfile] The taste profile.
|
192
|
+
# @param options [Hash] A customizable set of options.
|
193
|
+
# @option options [String] :id The ID of the taste profile. Required if name is omitted. Example: 'CAJTFEO131216286ED'.
|
194
|
+
# @option options [String] :name The name of the taste profile. Required if the ID is omitted. Example: 'My Favorite Artists'.
|
195
|
+
#
|
196
|
+
# @example taste_profile_profile
|
197
|
+
# Echowrap.taste_profile_profile
|
198
|
+
def taste_profile_profile(options={})
|
199
|
+
object_from_response(Echowrap::TasteProfile, :get, '/api/v4/catalog/profile', :catalog, options)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Returns data stored in the taste profile. Also returns Echo Nest IDs for items that have been resolved to Echo Nest IDs along with information requested via bucket. If item_id is not set, all items (subject to the limits of the start and results parameters) are returned, otherwise, only the items explicitly specified by item_id are returned.
|
203
|
+
#
|
204
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#status
|
205
|
+
# @authentication Requires api key
|
206
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
207
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
208
|
+
# @return [Echowrap::TasteProfile] The taste profile.
|
209
|
+
# @param options [Hash] A customizable set of options.
|
210
|
+
# @option options [String] :id The ID of the taste profile. Required if name is omitted. Example: 'CAJTFEO131216286ED'.
|
211
|
+
# @option options [String] :item_id The item id for the item in the taste profile. Not required, can send multiple. ID will be whatever ID was assigned for the item.
|
212
|
+
# @option options [String] :bucket Indicates what data should be returned for each item. Not required, can send multiple. Can by any of the following 'item_keyvalues', For song items: 'audio_summary', 'artist_familiarity', 'artist_hotttnesss', 'artist_location', 'song_hotttnesss', 'song_type', 'tracks', 'id:Rosetta-space' For artist items: 'biographies', 'blogs', 'doc_counts', 'familiarity', 'hotttnesss', 'images', 'artist_location', 'news', 'reviews', 'songs', 'terms', 'urls', 'video', 'years_active', 'id:Rosetta-space'
|
213
|
+
# @option options [Integer] :results The number of results desired.
|
214
|
+
# @option options [Integer] :start The desired index of the first result returned.
|
215
|
+
#
|
216
|
+
# @example taste_profile_read
|
217
|
+
# Echowrap.taste_profile_read
|
218
|
+
def taste_profile_read(options={})
|
219
|
+
object_from_response(Echowrap::TasteProfile, :get, '/api/v4/catalog/read', :catalog, options)
|
220
|
+
end
|
221
|
+
|
222
|
+
# Checks the status of a taste profile update.
|
223
|
+
#
|
224
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#status
|
225
|
+
# @authentication Requires api key
|
226
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
227
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
228
|
+
# @return [Echowrap::Status] The taste profile status.
|
229
|
+
# @param options [Hash] A customizable set of options.
|
230
|
+
# @option options [String] :ticket The ticket to check (returned by upload or update). Required. Example: 'e0ba094bbf98cd006283aa7de6780a83'.
|
231
|
+
#
|
232
|
+
# @example taste_profile_status
|
233
|
+
# Echowrap.taste_profile_status(:ticket => 'e0ba094bbf98cd006283aa7de6780a83')
|
234
|
+
def taste_profile_status(options={})
|
235
|
+
object_from_response(Echowrap::Status, :get, '/api/v4/catalog/status', nil, options)
|
236
|
+
end
|
237
|
+
|
238
|
+
# Returns feeds based on the artists in a taste profile. Unlike catalog/read method, the catalog/feed method interleaves items and sorts them by date.
|
239
|
+
#
|
240
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#list
|
241
|
+
# @authentication Requires api key
|
242
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
243
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
244
|
+
# @return [Array] Array of feeds
|
245
|
+
# @param options [Hash] A customizable set of options.
|
246
|
+
# @option options [String] :id The ID of the taste profile. Required if name is omitted. Example: 'CAJTFEO131216286ED'.
|
247
|
+
# @option options [String] :bucket Indicates what type of feed items should be returned for each artist in the taste profile. Not required, may send multiple. can be any combination of news, blogs, reviews, audio and video blogs. If omitted defaults to news.
|
248
|
+
# @option options [Integer] :results The number of results desired. Not required, defaults to 25.
|
249
|
+
# @option options [Integer] :start The desired index of the first result returned. Not required, defaults to 0.
|
250
|
+
# @option options [String] :since Limit the items to those that have occurred since the given date. Not required, if supplied must be in date format YYYY-mm-dd. Example: '2013-05-19'.
|
251
|
+
# @option options [String] :high_relevance if true only items that are highly relevant for this artist will be returned. Currently only news items are filtered for high relevance. Not required, defaults to 'false', must be one of ['true', 'false'].
|
252
|
+
#
|
253
|
+
# @example taste_profile_feed
|
254
|
+
# Echowrap.taste_profile_feed
|
255
|
+
def taste_profile_feed(options={})
|
256
|
+
objects_from_response(Echowrap::Feed, :get, '/api/v4/catalog/feed', :feed, options)
|
257
|
+
end
|
258
|
+
|
259
|
+
# Returns a list of all taste profiles that are similar to the given set of taste profiles. This method returns similar taste profiles of the given use type. Similarity search is restricted to taste profiles that were created with the caller's API key.
|
260
|
+
#
|
261
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#similar
|
262
|
+
# @authentication Requires api key
|
263
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
264
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
265
|
+
# @return [Array] Array of taste profiles
|
266
|
+
# @param options [Hash] A customizable set of options.
|
267
|
+
# @option options [String] :id The ID of the taste profile. Required, can send multiple up to 10. Example: 'CAJTFEO131216286ED'.
|
268
|
+
# @option options [Integer] :results The number of results desired. Not required, defaults to 25.
|
269
|
+
# @option options [Integer] :start The desired index of the first result returned. Not required, defaults to 0.
|
270
|
+
# @option options [String] :keyvalue Restrict results to taste profiles that have the given key/value pair. If no value is given, restrict results to all taste profiles that have the given key. Not required, may send multiple, Examples: ['yob', 'gender:female', 'zipcode:03103']
|
271
|
+
#
|
272
|
+
# @example taste_profile_similar
|
273
|
+
# Echowrap.taste_profile_similar
|
274
|
+
def taste_profile_similar(options={})
|
275
|
+
objects_from_response(Echowrap::TasteProfile, :get, '/api/v4/catalog/similar', :catalogs, options)
|
276
|
+
end
|
277
|
+
|
278
|
+
# Access the taste profile attributes.
|
279
|
+
#
|
280
|
+
# @see http://developer.echonest.com/docs/v4/taste_profile.html#predict
|
281
|
+
# @authentication Requires api key
|
282
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
283
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
284
|
+
# @return [Echowrap::TasteProfile] The taste profile.
|
285
|
+
# @param options [Hash] A customizable set of options.
|
286
|
+
# @option options [String] :id The ID of the taste profile. Required. Example: 'CAJTFEO131216286ED'.
|
287
|
+
# @option options [String] :category The attributes to be returned for the taste profile. Required, may send multiple, must be any of ['adventurousness', 'diversity', 'freshness', 'mainstreamness', 'top_years', 'top_styles', 'audio_features'] (audio features is only available for song-based profiles).
|
288
|
+
#
|
289
|
+
# @example taste_profile_predict
|
290
|
+
# Echowrap.taste_profile_predict
|
291
|
+
def taste_profile_predict(options={})
|
292
|
+
object_from_response(Echowrap::TasteProfile, :get, '/api/v4/catalog/predict', :catalog, options)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'echowrap/api/utils'
|
2
|
+
|
3
|
+
module Echowrap
|
4
|
+
module API
|
5
|
+
module Track
|
6
|
+
include Echowrap::API::Utils
|
7
|
+
|
8
|
+
# Get info about tracks given an id or md5. The md5 parameter is the file md5.
|
9
|
+
#
|
10
|
+
# @see http://developer.echonest.com/docs/v4/track.html
|
11
|
+
# @authentication Requires api key
|
12
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid. # @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
13
|
+
# @return [Echowrap::Track] The track.
|
14
|
+
# @param options [Hash] A customizable set of options.
|
15
|
+
# @option options [String] :id The ID of the track. Required if md5 is not provided. Example: 'TRTLKZV12E5AC92E11'.
|
16
|
+
# @option options [String] :md5 The MD5 of the track. Required if ID is not provided. Example: '881f4e47e88e8b570e34a3b49c8262ac'.
|
17
|
+
# @option options [String] :bucket The type of track data that should be returned. Example: audio_summary.
|
18
|
+
# @example Profile via id
|
19
|
+
# Echowrap.track_profile(:id => "TRTLKZV12E5AC92E11")
|
20
|
+
def track_profile(options={})
|
21
|
+
options.merge(:bucket => 'audio_summary') if options[:bucket].nil?
|
22
|
+
object_from_response(Echowrap::Track, :get, '/api/v4/track/profile', :track, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
# 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.
|
26
|
+
#
|
27
|
+
# @see http://developer.echonest.com/docs/v4/track.html
|
28
|
+
# @authentication Requires api key
|
29
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied api key is not valid.
|
30
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
31
|
+
# @return [Echowrap::Track] The track.
|
32
|
+
# @param options [Hash] A customizable set of options.
|
33
|
+
# @option options [String] :url A url to an audio file. Cannot be combined with uploading local audio file. Example: http://example.com/audio.mp3.
|
34
|
+
# @option options [File] :track The track data. Cannot be
|
35
|
+
# combined with url option
|
36
|
+
# @option options [String] :filetype The type of audio file to be analyzed. Optional if uploading a local file, will be determined from file if not explicitly passed. Must be one of ['wav', 'mp3', 'au', 'ogg', 'm4a', 'mp4'].
|
37
|
+
# @example Upload
|
38
|
+
# Echowrap.track_upload(:url => "http://example.com/audio.mp3")
|
39
|
+
# Echowrap.track_upload(:track => File.new('audio.mp3'))
|
40
|
+
def track_upload(options={})
|
41
|
+
options.merge(filetype: File.extname(options[:track]).gsub('.', '')) if options[:track] && options[:filetype].nil?
|
42
|
+
object_from_response(Echowrap::Track, :post, '/api/v4/track/upload', :track, options)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Get analysis info on tracks given an analysis_url. This method is not explicitly described by the Echowrap API and is provided as a helper.
|
46
|
+
#
|
47
|
+
# @see http://developer.echonest.com/docs/v4/track.html
|
48
|
+
# @authentication Requires analysis url
|
49
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied analysis url is not valid.
|
50
|
+
# @raise [Echowrap::Error::Unauthorized] Error raised when supplied analysis url is expired.
|
51
|
+
# @return [Echowrap::Track] The track.
|
52
|
+
# @param options [Hash] A customizable set of options.
|
53
|
+
# @option options [String] :url The analysis url. Required. Example: 'http://echonest-analysis.s3.amazonaws.com/TR/TREYOVK13C9786E66B/3/full.json?AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1367708437&Signature=pPUyoKFvgwXj2FORgohKOA6pRPc%3D'.
|
54
|
+
# @example Analysis
|
55
|
+
# Echowrap.track_analysis(:url => "http://echonest-analysis.s3.amazonaws.com/TR/TREYOVK13C9786E66B/3/full.json?AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1367708437&Signature=pPUyoKFvgwXj2FORgohKOA6pRPc%3D")
|
56
|
+
def track_analysis(options={})
|
57
|
+
url = options.delete(:url)
|
58
|
+
response = send(:get, url, options)
|
59
|
+
Echowrap::Analysis.new(response[:body])
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
module Echowrap
|
3
|
+
module API
|
4
|
+
module Utils
|
5
|
+
|
6
|
+
SUCCESS = 0
|
7
|
+
MISSING_OR_INVALID_KEY = 1
|
8
|
+
API_KEY_CANNOT_CALL_THIS_METHOD = 2
|
9
|
+
RATE_LIMIT_EXCEEDED = 3
|
10
|
+
MISSING_PARAMETER = 4
|
11
|
+
INVALID_PARAMETER = 5
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# @param klass [Class]
|
16
|
+
# @param request_method [Symbol]
|
17
|
+
# @param path [String]
|
18
|
+
# @param options [Hash]
|
19
|
+
# @return [Array]
|
20
|
+
def objects_from_response(klass, request_method, path, object_key, options={})
|
21
|
+
response = send(request_method.to_sym, path, options)[:body][:response][object_key]
|
22
|
+
objects_from_array(klass, response)
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param klass [Class]
|
26
|
+
# @param array [Array]
|
27
|
+
# @return [Array]
|
28
|
+
def objects_from_array(klass, array)
|
29
|
+
array.map do |element|
|
30
|
+
klass.new(element)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param klass [Class]
|
35
|
+
# @param request_method [Symbol]
|
36
|
+
# @param path [String]
|
37
|
+
# @param object_key [Symbol]
|
38
|
+
# @param options [Hash]
|
39
|
+
# @return [Object]
|
40
|
+
def object_from_response(klass, request_method, path, object_key, options={})
|
41
|
+
response = send(request_method.to_sym, path, options)[:body][:response]
|
42
|
+
response = response[object_key] if object_key
|
43
|
+
klass.new(response)
|
44
|
+
end
|
45
|
+
|
46
|
+
# @param klass [Class]
|
47
|
+
# @param request_method [Symbol]
|
48
|
+
# @param path [String]
|
49
|
+
# @param options [Hash]
|
50
|
+
# @return [Object]
|
51
|
+
def boolean_from_response(request_method, path, options={})
|
52
|
+
response = send(request_method.to_sym, path, options)
|
53
|
+
response[:body][:response][:status][:code] == SUCCESS
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'echowrap/base'
|
2
|
+
|
3
|
+
module Echowrap
|
4
|
+
class Artist < Echowrap::Base
|
5
|
+
attr_reader :name, :twitter, :id, :familiarity, :hotttnesss
|
6
|
+
|
7
|
+
# @return [Array]
|
8
|
+
def biographies
|
9
|
+
@biographies ||= map_collection(Echowrap::Biography, :biographies)
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Array]
|
13
|
+
def blogs
|
14
|
+
@blogs ||= map_collection(Echowrap::Blog, :blogs)
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Echowrap::DocCounts]
|
18
|
+
def doc_counts
|
19
|
+
@doc_counts ||= Echowrap::DocCounts.new(@attrs[:doc_counts])
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Array]
|
23
|
+
def images
|
24
|
+
@images ||= map_collection(Echowrap::Image, :images)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Array]
|
28
|
+
def foreign_ids
|
29
|
+
@foreign_ids ||= map_collection(Echowrap::ForeignId, :foreign_ids)
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Echowrap::Location]
|
33
|
+
def location
|
34
|
+
@location ||= Echowrap::Location.new(@attrs[:artist_location])
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Array]
|
38
|
+
def news
|
39
|
+
@news ||= map_collection(Echowrap::NewsArticle, :news)
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Array]
|
43
|
+
def reviews
|
44
|
+
@reviews ||= map_collection(Echowrap::Review, :reviews)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Array]
|
48
|
+
def songs
|
49
|
+
@songs ||= map_collection(Echowrap::Song, :songs)
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Array]
|
53
|
+
def terms
|
54
|
+
@terms ||= map_collection(Echowrap::Term, :terms)
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [Echowrap::Urls]
|
58
|
+
def urls
|
59
|
+
@urls ||= Echowrap::Urls.new(@attrs[:urls])
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [Array]
|
63
|
+
def video
|
64
|
+
@video ||= map_collection(Echowrap::Video, :video)
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [Array]
|
68
|
+
def years_active
|
69
|
+
@years_active ||= map_collection(Echowrap::YearsActive, :years_active)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'echowrap/base'
|
2
|
+
|
3
|
+
module Echowrap
|
4
|
+
class Asset < Echowrap::Base
|
5
|
+
attr_reader :explicit, :filename, :id, :release, :title, :type, :year
|
6
|
+
|
7
|
+
def echonest_ids
|
8
|
+
@echonest_ids ||= map_collection(Echowrap::EchonestId, :echonest_ids)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'echowrap/base'
|
2
|
+
|
3
|
+
module Echowrap
|
4
|
+
class AudioSummary < Echowrap::Base
|
5
|
+
attr_reader :acousticness, :analysis_url, :audio_md5, :danceability, :duration, :energy,
|
6
|
+
:key, :liveness, :loudness, :mode, :speechiness, :liveness, :tempo, :time_signature,
|
7
|
+
:valence
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Echowrap
|
2
|
+
class Base
|
3
|
+
# Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key
|
4
|
+
#
|
5
|
+
# @param attrs [Array, Set, Symbol]
|
6
|
+
def self.attr_reader(*attrs)
|
7
|
+
#@attr_readers ||= []
|
8
|
+
#@attr_readers.concat attrs
|
9
|
+
|
10
|
+
mod = Module.new do
|
11
|
+
attrs.each do |attribute|
|
12
|
+
define_method attribute do
|
13
|
+
@attrs[attribute.to_sym] if @attrs
|
14
|
+
end
|
15
|
+
define_method "#{attribute}?" do
|
16
|
+
!!@attrs[attribute.to_sym]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
const_set(:Attributes, mod)
|
21
|
+
include mod
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param other [Echowrap::Base]
|
25
|
+
# @return [Boolean]
|
26
|
+
def ==(other)
|
27
|
+
super || attr_equal(:id, other) || attrs_equal(other)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Initializes a new object
|
31
|
+
#
|
32
|
+
# @param attrs [Hash]
|
33
|
+
# @return [Echowrap::Base]
|
34
|
+
def initialize(attrs={})
|
35
|
+
@attrs = attrs
|
36
|
+
end
|
37
|
+
|
38
|
+
# Retrieve the attributes of an object
|
39
|
+
#
|
40
|
+
# @return [Hash]
|
41
|
+
def attrs
|
42
|
+
@attrs
|
43
|
+
end
|
44
|
+
alias to_hash attrs
|
45
|
+
|
46
|
+
# Update the attributes of an object
|
47
|
+
#
|
48
|
+
# @param attrs [Hash]
|
49
|
+
# @return [Echowrap::Base]
|
50
|
+
def update(attrs)
|
51
|
+
@attrs.update(attrs)
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
#def self.attr_readers
|
56
|
+
#@attr_readers
|
57
|
+
#end
|
58
|
+
|
59
|
+
#def attr_readers
|
60
|
+
#self.class.attr_readers
|
61
|
+
#end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
# @param attr [Symbol]
|
66
|
+
# @param other [Echowrap::Base]
|
67
|
+
# @return [Boolean]
|
68
|
+
def attr_equal(attr, other)
|
69
|
+
self.class == other.class && !other.send(attr).nil? && send(attr) == other.send(attr)
|
70
|
+
end
|
71
|
+
|
72
|
+
# @param other [Echowrap::Base]
|
73
|
+
# @return [Boolean]
|
74
|
+
def attrs_equal(other)
|
75
|
+
self.class == other.class && !other.attrs.empty? && attrs == other.attrs
|
76
|
+
end
|
77
|
+
|
78
|
+
# @param klass [Class]
|
79
|
+
# @param key [Symbol]
|
80
|
+
# @return [Array]
|
81
|
+
def map_collection(klass, key)
|
82
|
+
Array(@attrs[key.to_sym]).map do |entity|
|
83
|
+
klass.new(entity)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|