Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Soundcloud API not returning all tracks from playlist through Python

I recently started to use the Soundcloud API to develop a simple app which saves data on playlists. However, it seems to me that not all tracks from playlists are being returned.

I'm using the following code:

import soundcloud, shelve, time

client = soundcloud.Client(client_id=CLIENT_ID,
                           client_secret=CLIENT_SECRET,
                           username=E-MAIL,
                           password=PASSWORD)

playlists = client.get('/users/24196709/playlists', limit=1)

tracknames = []
trackids= []

for pl in playlists:
    for track in pl.tracks:
        print(track['title'])
        tracknames.append(track['title'])
        trackids.append(track['id'])

print(tracknames)

Using it on this playlist: https://soundcloud.com/michiel-tammeling/sets/icecubes which contains 13 tracks, however the code only returns 11.

Any help would be much appreciated.

like image 863
Michael Avatar asked Apr 20 '16 20:04

Michael


People also ask

Why do songs disappear from my SoundCloud playlist?

Tracks may disappear from playlists due to the track being made private or removed from SoundCloud.

Is there a limit on playlists on SoundCloud?

However, public playlists will be pushed to your followers' Streams, so make sure that the tracks within the playlist are also public and can be viewed by others. We also recommend limiting the number of tracks in your playlist to a maximum of 250 for it to easily load.

How do playlists work on SoundCloud?

Playlists are sets or 'albums' that you can create using your own or other people's tracks on SoundCloud. You can view playlists you have liked or created on your Collections page through the playlist tab. Or you can view just the playlists that you have created through the Playlist tab.

Is the SoundCloud API free?

Access to the SoundCloud® API is currently provided free of charge, but SoundCloud reserves the right to charge at some point in the future.


1 Answers

This can't be solved unfortunately. Lots of topics on this issue already. The thing is that the playlist API returns all tracks in the playlist, but the tracks API returns only tracks that are not protected. Since you already figured out which 2 tracks where missing I verified this and they both return a 403 when you try to use the track API. So those 2 tracks are somehow not accessible using the track API.

Some more background:

SoundCloud Playlist tracks is empty

SoundCloud emailed back saying they have introduced an option for right holders to disable all API access to tracks by default, returning this 403 error when requested. They also said it's understandable that this is a confusing feature, and that they hope to make it more clear.

And @nickf the tech lead of soundcloud says:

Yep -- there's many reasons that a track might not show up to you. It could be taken down by the rightsholder of the track, made private or deleted by the uploader, or (and this is the tricky one) blocked in certain territories. Calculating the policies of all of the tracks of a user every time it is fetched isn't quite feasible, so sometimes this number will be inaccurate (depending on who is asking and where they are). – nickf Apr 14 at 22:37

like image 89
DelGurth Avatar answered Nov 03 '22 22:11

DelGurth