Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/beatport/catalog/track.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ def self.most_popular_for_label(id, options = {})
options[:collection] = true
Client.retrieve "most-popular/label", Track, options
end

# also works for multiple id's as input
def self.similar(id, options = {})
options[:id] = id
options[:collection] = true
Client.retrieve "tracks/similar", Track, options
end

def similar(options = {})
@similar ||= Track.similar(id, options)
end

end
end
Expand Down
10 changes: 10 additions & 0 deletions spec/catalog/track_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ module Beatport::Catalog
end
end
end
describe '.similar' do
it "should get a list of tracks similar to track with id 1217790" do
tracks = Track.similar 1217790
tracks.length.should be > 1
end
it "should get a list of tracks similar to a list of track ids" do
tracks = Track.similar "4166013,1217790"
tracks.length.should be > 1
end
end
end
end