Ahsan
Ahsan

Reputation: 650

Rails how to get SoundCloud track information using SoundCloud song URL

In my rails project, I want to get SoundCloud track/song title, description, provider data using song url given by user from his SoundCloud account or any SoundCloud link.

Upvotes: 3

Views: 393

Answers (1)

insertusernamehere
insertusernamehere

Reputation: 23600

You can use the SoundCloud API for this - see section SoundCloud URLs:

If you have a permalink URL to a particular resource, but need more information such as an ID or other property. In these cases, you can use the /resolve endpoint to extract a full representation of the resource.

There's also an example using Ruby:

require 'soundcloud'

# create client with your app's credentials
client = Soundcloud.new(:client_id => 'YOUR_CLIENT_ID')

# a permalink to a track
track_url = 'http://soundcloud.com/forss/voca-nomen-tuum'

# resolve track URL into track resource
track = client.get('/resolve', :url => track_url)

# now that we have the track id, we can get a list of comments, for example
client.get("/tracks/#{track.id}/comments").each do |comment|
  puts "Someone said: #{comment.body} at #{comment.timestamp}"
end

Upvotes: 2

Related Questions