2

I'm trying to filter a single SoundCloud user's tracks with a query (or even a tags/genre filter). I can get a user's tracks, but as soon as I add a query parameter, it returns all sound cloud users tracks.

This doesn't work:

SC.get('/users/00001/tracks', {q: 'Black Night'}, function(tracks) {
   // returns tracks from all soundcloud users which contain 'Black Night'
   // rather than the single user    
});

Nor does this:

SC.get('/tracks', {user_id: '00001', q: 'Black Night'}, function(tracks) {
   // returns tracks from all soundcloud users which contain 'Black Night'
   // rather than the single user    
});
alex
  • 157
  • 2
  • 10
  • Duplicate of http://stackoverflow.com/questions/14752471/how-to-search-specific-users-tracks-by-tag-with-the-sound-cloud-api. It seems like what you did should work. But it doesn't. I wrote SoundCloud about it and I haven't heard back. – MikeSmithDev Mar 01 '13 at 05:06

2 Answers2

1

soundcloud api does not work that way.

you can search All tracks by term, genre, bpm, date etc or you can get user resources (tracks, favorites, groups, followers etc)

the best way to search inside tracks or any other user resource, is to get all results, and do the search inside the results.

Here under Subresources you can find /users/{id}/tracks - list of tracks of the user

cucko
  • 1,436
  • 11
  • 25
  • Can you give me an example of how you would filter a single user's tracks? Or are suggesting that it can't be done at the API level. – alex Feb 25 '13 at 14:40
  • But the goal is to return a filtered result from the user's tracks. I am able to get a single user's tracks. I want to filter it. Get one user's "folk" genre tracks for example. – alex Feb 25 '13 at 16:44
  • read again my answer. "soundcloud api does not work that way. you can search `All` tracks by term, genre, bpm, date etc or you can get `user resources` (tracks, favorites, groups, followers etc)" – cucko Feb 25 '13 at 17:10
1

You would first get all the songs by that specific user, for that you can use the code you used.

After that, you need to loop through all the songs you just retrieved and assign tracks[i].genre to a variable (let's say var track_genre)

Next, check if track_genre === myGenre (a parameter you give the function, which the user can choose)

If it's the case, go ahead and oEmbed the widget

I guess the main takeaway would be that you CAN access the genre of the songs you retrieved with 'SC.get' and filter on that, but you CANNOT SC.get specific genres FROM a specific user.

Anyway, that's how I just gotten around this particular problem; I'm sure there'd be better solutions, but this one works so... ;-)

mlemay
  • 1,622
  • 2
  • 32
  • 53
kevin
  • 114
  • 2
  • 5