How can I merge playlists via API?

This was solved by a kind person on Reddit who pointed out that the format of the add_to_playlist_url was not correct (all other code is mine). It seems the solution was using a PUT request to a URL in this format below. So I create the playlist of Local tracks, then pull the Key for that playlist, and then write the Tidal tracks to the playlist like so:

add_to_playlist_url = f"{PLEX_SERVER_URL}/playlists/{EXISTING_PLAYLIST_RATINGKEY}/items?uri=provider%3A%2F%2Ftv.plex.provider.music%2Flibrary%2Fmetadata%2F{tidal_id_str}"

Here’s the final script which I posted on my Github. It may not be the most elegant code ever written, but it works. Since I have a lot of bootlegs in my collection, I exclude tracks and albums with a date format (e.g. YYYY-MM-DD) or with the words “live”, “concert”, or “sbd”. It also prompts which Plex user account to add the playlist to, but I include a modified function that adds it to the admin account by default if you don’t want the ability to select a user.