earworm.lol: breaking down music streaming walls
Blazing-fast universal music links with a little help from Cloudflare.
I’ve recently moved away from Spotify, but the social friction is real. You send your friend a Tidal link, but they are on Deezer. They send you an Apple Music link, but you’re on Tidal now. I want to share music links that just *work for everyone!*
Existing services that try to solve this either need me to visit their site first and paste a link (that’s too much friction still), or they are much too slow, taking multiple seconds to load (looking at you, song.link).
So in a moment of frustration, I decided to code my own solution. Since all good domains were gone, and anyplat.fm was too pricey for me, i settled on earworm.lol/. Prefix your Spotify/Deezer/Tidal or Apple Music links to any track/album/artist with this url, and visitors can listen to the music on their platform of choice:
Example: earworm.lol/open.spotify.com/track/5BBK1WoaiD3b3sJ2UysLuM
My Needs
- Has to work for the main (western) platforms.
- Be as fast as (in)humanly possible.
- Clean design, no fluff, no ads, no tracking.
- Just prepend the link and you’re done.
- It needs to run for basically free.
- Nice-to-have: 30s streamable track previews
Cloudflare to the rescue!
Thankfully, Cloudflare is suited well for this and we can easily meet the “fast and free” requirement, running this entire thing on the “Edge” without a traditional server.
- Compute: Cloudflare Workers (running Hono, a tiny web framework).
- Database: Workers KV (Key-Value storage) for caching.
- Protection: Cloudflare Rate Limiting (just in case).
The trick for speed: lazy resolution
The reason other services are slow (I suppose) is because they try to resolve everything at once. You give them a Spotify link, and they immediately go ask Apple Music, Tidal, Deezer, and YouTube: “Hey, do you have this song?” waiting for all of them to reply before showing you the page. Even if they don’t wait until all results are back to serve you the page, that’s still a lot of API calls, and I want to reduce those as much as possible, too.
But then I realized: I don’t actually need to do that. Instead, I split the process into two phases:
- On load of the universal link page, only one API call is done to the source platform of your link. The page (with the song metadata) is returned (almost) instantly, but its platform buttons link to a special redirect route on my domain still.
- Once your friend visits the site and clicks his platform button, only then is the track/album/artist identifier resolved to the target platform and the user is forwarded accordingly.
Both the resolution steps are cached in two cloudflare KV caches, so subsequent hits are instant (O(1) baby!).
That’s all!
Ceterum censeo Spotify esse delendam
Read this long Wikipedia article about criticisms of Spotify to learn, why! (And it somehow doesn’t even mention the unlabeled AI slop).