Deleting A Playlist
Wraps around this Spotify API endpoint
Note
It is not currently possible to delete a playlist entirely on Spotify, the best alternative is to unfollow it, which is the same as "deleting" a playlist through the web players or desktop app.
Because of this, this method just unfollows a playlist.
How to use
After getting a playlist through either Spotify.Playlists.GetPlaylist()
or creating a new playlist with Spotify.Playlists.CreatePlaylist()
, the .Delete()
method of the playlist object can be called to "delete" the playlist.
Example
This example will:
A) Create a new (empty and private) playlist named Test 123
with the description This is an example playlist made by Spotify.ahk
by calling Spotify.Playlists.CreatePlaylist()
B) Get 3 track objects with calls to Spotify.Tracks.GetTrack()
.
C) Add 5 tracks to the playlist, 3 copies of Ocean Man and the two other tracks, all using the .AddTrack()
method.
D) Wait 20 seconds, then delete the playlist
NewPlaylist := Spotify.Playlists.CreatePlaylist("Test 1234", false, "This is a Spotify.ahk test playlist")
FirstTrack := Spotify.Tracks.GetTrack("5ogtb9bGQoH8CjZNxmbNHR")
SecondTrack := Spotify.Tracks.GetTrack("2yYSMsrFJ6m7ePtLxQZZBF")
OceanMan := Spotify.Tracks.GetTrack("6M14BiCN00nOsba4JaYsHW")
NewPlaylist.AddTrack(FirstTrack)
NewPlaylist.AddTrack(SecondTrack)
loop, 3 {
NewPlaylist.AddTrack(OceanMan)
}
Sleep, 20000
NewPlaylist.Delete()
An alternative way to do this without getting any full track objects is the Spotify.Playlists.PlaylistAddTrack()
method and the Spotify.Playlists.DeletePlaylist()
method, which both a playlist ID and track ID, which would save us some web API calls.
NewPlaylist := Spotify.Playlists.CreatePlaylist("Test 1234", false, "This is a Spotify.ahk test playlist")
Spotify.Playlists.PlaylistAddTrack(NewPlaylist.ID, "5ogtb9bGQoH8CjZNxmbNHR")
Spotify.Playlists.PlaylistAddTrack(NewPlaylist.ID, "2yYSMsrFJ6m7ePtLxQZZBF")
loop, 3 {
Spotify.Playlists.PlaylistAddTrack(NewPlaylist.ID, "6M14BiCN00nOsba4JaYsHW")
}
Sleep, 20000
Spotify.Playlists.DeletePlaylist(NewPlaylist.ID)