[GH-ISSUE #487] 'insert_before' for 'user_playlist_replace_tracks' function? Or reorder against track ids for 'user_playlist_reorder_tracks' function? #286

Closed
opened 2026-02-27 23:21:48 +03:00 by kerem · 2 comments
Owner

Originally created by @sjames272727 on GitHub (Apr 29, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/487

I'm trying to reorder a playlist with above 100 tracks using either the 'user_playlist_reorder_tracks' function or the 'user_playlist_reorder_tracks' function. I can't use the 'user_playlist_add_tracks' function because I need to maintain the 'added_at' date.

So what I'm trying to do is segment the playlist into 100s so that I don't go above the 100 track limit.

Is there a way to use the 'user_playlist_reorder_tracks' function and reorder it against a list of track ids. Or use the 'user_playlist_reorder_tracks' and choose the the range of tracks to replace?

Sorry if this is a stupid question, I'm new to the Spotipy library and Python in general.

Originally created by @sjames272727 on GitHub (Apr 29, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/487 I'm trying to reorder a playlist with above 100 tracks using either the 'user_playlist_reorder_tracks' function or the 'user_playlist_reorder_tracks' function. I can't use the 'user_playlist_add_tracks' function because I need to maintain the 'added_at' date. So what I'm trying to do is segment the playlist into 100s so that I don't go above the 100 track limit. Is there a way to use the 'user_playlist_reorder_tracks' function and reorder it against a list of track ids. Or use the 'user_playlist_reorder_tracks' and choose the the range of tracks to replace? Sorry if this is a stupid question, I'm new to the Spotipy library and Python in general.
kerem closed this issue 2026-02-27 23:21:49 +03:00
Author
Owner

@stephanebruckert commented on GitHub (Apr 30, 2020):

Is there a way to use the 'user_playlist_reorder_tracks' function and reorder it against a list of track ids. Or use the 'user_playlist_reorder_tracks' and choose the the range of tracks to replace?

There is probably a way but you will have to write the code for it. What user_playlist_reorder_tracks does is switch one or multiple tracks that follow each other to a new index in the same playlist. See the doc https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.user_playlist_reorder_tracks

Here is an example that reverts a playlist https://gist.github.com/stephanebruckert/d0cc70508e72273995d297f6af6fad13

<!-- gh-comment-id:622149813 --> @stephanebruckert commented on GitHub (Apr 30, 2020): > Is there a way to use the 'user_playlist_reorder_tracks' function and reorder it against a list of track ids. Or use the 'user_playlist_reorder_tracks' and choose the the range of tracks to replace? There is probably a way but you will have to write the code for it. What `user_playlist_reorder_tracks` does is switch one or multiple tracks that follow each other to a new index in the same playlist. See the doc https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.user_playlist_reorder_tracks Here is an example that reverts a playlist https://gist.github.com/stephanebruckert/d0cc70508e72273995d297f6af6fad13
Author
Owner

@sjames272727 commented on GitHub (May 1, 2020):

There is probably a way but you will have to write the code for it. What user_playlist_reorder_tracks does is switch one or multiple tracks that follow each other to a new index in the same playlist. See the doc https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.user_playlist_reorder_tracks

Yes I actually did find a way myself, but it was extremely slow, where it reordered about 1 track every 1.5 seconds. It was actually pretty similar to the example you gave.

Thank you, I'll probably just use the example you gave and limit the number of tracks to be reordered to 300 tracks in order to prevent crashing.

<!-- gh-comment-id:622261539 --> @sjames272727 commented on GitHub (May 1, 2020): > There is probably a way but you will have to write the code for it. What `user_playlist_reorder_tracks` does is switch one or multiple tracks that follow each other to a new index in the same playlist. See the doc https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.user_playlist_reorder_tracks Yes I actually did find a way myself, but it was extremely slow, where it reordered about 1 track every 1.5 seconds. It was actually pretty similar to the example you gave. Thank you, I'll probably just use the example you gave and limit the number of tracks to be reordered to 300 tracks in order to prevent crashing.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#286
No description provided.