Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SoundCloud API - Playback Count is smaller than actual count

I am using soundcloud api through python SDK.

When I get the tracks data through 'Search', the track attribute 'playback_count' seems to be smaller than the actual count seen on the web.

How can I avoid this problem and get the actual playback_count??

(ex. this track's playback_count gives me 2700, but its actually 15k when displayed on the web https://soundcloud.com/drumandbassarena/ltj-bukem-soundcrash-mix-march-2016 )

note: this problem does not occur for comments or likes.

following is my code

##Search##
tracks = client.get('/tracks', q=querytext, created_at={'from':startdate},duration={'from':startdur},limit=200)

outputlist = []
trackinfo = {}
resultnum = 0

for t in tracks:
    trackinfo = {}
    resultnum += 1

    trackinfo["id"] = resultnum
    trackinfo["title"] =t.title
    trackinfo["username"]= t.user["username"]
    trackinfo["created_at"]= t.created_at[:-5]
    trackinfo["genre"] = t.genre
    trackinfo["plays"] = t.playback_count
    trackinfo["comments"] = t.comment_count
    trackinfo["likes"] =t.likes_count
    trackinfo["url"] = t.permalink_url

    outputlist.append(trackinfo)
like image 698
mildmark Avatar asked Apr 04 '16 01:04

mildmark


2 Answers

There is an issue with the playback count being incorrect when reported via the API.

I have encountered this when getting data via the /me endpoint for activity and likes to mention a couple.

The first image shows the information returned when accessing the sound returned for the currently playing track in the soundcloud widget

Information when accessing via the "Sound" returned for the currently playing track in the soundcloud widget

Information returned via the api for the me/activities endpoint

information for the same track via the /me/activities endpoint of the API for

like image 161
SteveE Avatar answered Oct 02 '22 01:10

SteveE


Looking at the SoundCloud website, they actually call a second version of the API to populate the track list on the user page. It's similar to the documented version, but not quite the same.

If you issue a request to https://api-v2.soundcloud.com/stream/users/[userid]?limit=20&client_id=[clientid] then you'll get back a JSON object showing the same numbers you see on the web.

Since this is an undocumented version, I'm sure it'll change the next time they update their website.

like image 41
Nathan Bidwell Avatar answered Oct 02 '22 00:10

Nathan Bidwell