Reputation: 21
I have been trying to find a way to clear a playlist/set of all tracks using the SoundCloud API. I have no problem adding tracks to a playlist/set, but when I attempt to remove them nothing happens. I have played around with the DELETE method, but all it is doing is deleting the whole playlist/set.
I have tried this, but the playlist/set continues to have the same tracks in it.
# get a playlist
playlist = client.get("/me/playlists").first
# clearing tracks from playlist
playlist.tracks.clear
# send update/put request to playlist
playlist = client.put(playlist.uri, :playlist => {
:tracks => playlist.tracks
})
Upvotes: 2
Views: 7579
Reputation: 11
I just figured out how to do it in python: PUTing just an empty collection won't be enough to clear all tracks from the desired playlist.
tracks = map(lambda id: dict(id=id), [0])
client.put(playlist.uri, playlist={'tracks':tracks})
This will do the trick and empty the playlist
Upvotes: 1
Reputation: 546443
The way it works on soundcloud.com is by sending this JSON data via a PUT to playlists/:id
{ playlist: { tracks: [] } }
Upvotes: 1