Persisting previous added_at property when re-adding tracks to a playlist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
*Using Web API*
I'm trying to sort playlist tracks by date added. I'm only trying to sort playlists owned by the user. Things I have tried:
1. Clearing playlist tracks with 'Update Playlist Items' passed an empty uris array and then re-adding them with 'Add Items to Playlist'. Pros: it's fast. Cons: 'Add Items to Playlist' updates the added_at property.
2. Replacing playlist tracks with 'Update Playlist Items' passed an array of uris. Pros: it's fast and it persists the added_at property. Cons: no ability to specify offset or range. Entire playlist is wiped (if I try to replace 150 songs, I'll end up with 50. The first pass replaces the 150 songs with 100, the second pass replaces the 100 with 50). It's possible I'm using this endpoint wrong (documentation lacks clarity), if so please let me know.
3. Reordering playlist tracks one-by-one with 'Update Playlist Items'. Pros: it works. Cons: It's slow with an asterisk. Going one-by-one with a playlist of 150 songs, I'll hit the rate limit before I get through them all. Going one-by-one while being mindful (fearful) of the rate limit is slow. Now I don't actually go one-by-one, I use batches where I can. Synchronous batching is rather limited. There are some really nice best case scenarios with amazing speed ups and then there's not so great scenarios like reversing the list of tracks. Asynchronous batching...honestly it's difficult to talk about with the mental scars still being fresh. Things don't go as you would expect them to. Debugging is a nightmare when all I have to go on is a snapshot_id and imagination. Considering the time spent on code execution is almost negligible and the bottleneck is the api call response time (plus hitting a rate limit here will hurt exponentially more), I starting to feel like it's not worth the headache.
In conclusion, if there's a better method I haven't tried please let me know. If there's a better way to do #3 or optimization techniques that would help, please let me know. Otherwise, I'd like to propose a feature where the 'Add Items to Playlist' persists the added_at property like 'Update Playlist Items', perhaps with some sort of flag or a feature where 'Update Playlist Items' doesn't nuke the entire playlist, perhaps by specifying additional parameters like range_start, range_length, insert_before, or whatever you guys think would work best.
- Labels:
-
API Question
-
Discussion
-
Feature Request
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page