0

I am trying to remove a track from a playlist and the information I know about the track is the spotify URI, the name of the track and the artist. However, I don't know the position of the track in the playlist.
The function to remove the track is the following: spotify.Playlists.remove_tracks(tracks) Parameters: tracks (list of int) – A list of track positions to be removed from the playlist

I haven't found any callbacks or class method that would provide this information except upon adding the track to the playlist, which may have happened in another session.
Has anyone done this successfully and if so, could you point me to how you were able to do it?

Thanks

1 Answers1

0

I haven't used PySpotify myself, but looking at the docs, it says that a Playlist is an iterable sequence of Tracks. I think you should be able to iterate over the tracks and use str(spotify.Link.from_track(track)) to get the link for each track. Then you can easily enough look for the indices that match your track URI.

Weeble
  • 17,058
  • 3
  • 60
  • 75