#๐Ÿ”’ Spotipy track ID fetching in the long term

7 messages ยท Page 1 of 1 (latest)

buoyant breach
#

I am currently working on a project that stores files as Spotify playlists. I coincidentally already had a playlist with almost exactly the right amount of tracks, so I used Spotify to fetch all 8192 (2^13) track IDs and made a lookup dictionary between each track ID and a corresponding 13bit string of binary. My program reads the binary and adds the corresponding track IDs to a playlist to write the file to the playlist, and to read the file from the playlist I fetch all the IDs from the playlist and uses the lookup dictionary to convert it back to binary.

The problem I am having: even though I am using the original IDs to add the tracks to the playlists, for a few tracks, Spotify is now fetching a different ID. This is causing errors because the new ID that is being fetched is not in the lookup dict.

Manually fixing these changed IDs is a lot of work, since you have to locate the ID, and it is essentially whack a mole.

The only solution I can think of is excepting the error during the read process and if the error comes up, do some sort of recalibration process where I add all the IDs to a temporary playlist, then fetch them all again and update the dictionary as necessary, but that would take forever as the API is limited to 100 tracks per request, so that is 160 API requests.

Is there a better way to handle the situation?

lament smeltBOT
#

@buoyant breach

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

buoyant breach
#

Bump

buoyant breach
#

.

buoyant breach
#

.

lament smeltBOT
#

@buoyant breach

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.