Spotify Archivist
So for the last 10 years I've been adding songs to my Spotify liked songs. It's great but every once in a while a song comes on and I think... "do I really still like this song?" I decided that I wanted a way to archive my likes annually and then clear them1.
So with a few minute and a desire to experiment with Claude.ai and it's code authoring I described what I wanted the code to do: create a playlist per year that included the songs that I liked on that year, then optionally remove them from the likes songs list (always optionally for destructive things you aren't sure of). Let's talk about how it went and what I wound up with.
First... the initial prompt for Claude.ai:
write a shell node script that reads all of my liked/saved songs from spotify's api, and creates playlists of them based on the year that they were saved. The playlist names should be structured like "Liked Songs {year-goes-here}".
Provide an option to clear the liked songs after all of that is complete, but don't make it the default behavior.
This resulted in a mostly workable version. With a few more prompts and revisions it produced a workable tool, with env var handling, a mostly good readme, and some code that worked for getting a token for the Spotify api.
From a functional perspective it was mostly there, a few bits where more complicated then they needed to be, so I did some tidying and called it good. This was a simple tool, nothing that really needs to be production ready, and so I shipped it.
Before we go further it's worth a few observations about generative ai and coding.
This problem was particularly well suited for generative ai to write the code for. It is well constrained. It is stand alone so requires a limited scope of context. It's knitting together APIs and with patterns. These are things that generative ai is good at creating in my experience so far.
Writing something like this is not the same thing as writing larger applications, nor is it the same as editing and expanding large codebases. Token count starts to be problematic there.
But things like this, things like unit tests, things like GitHub workflows, things like infrastructure as code, things potentially like readme files, are much better fits for the talents of generative AI at the moment.
Back to the main thread here.
As I started thinking about the approaching end of year, I realized that reporting on some of the data around what I liked musically during a year would at least be interesting for me. So I set out on the next phase.
Claude and ChatGPT fleshed out a first pass at sentiment analysis. Suggesting npm modules writing a first pass at the code. And it worked! Until it didn't.
The modules that it chose were fine but the lyric fetch module quickly stopped working. That wasn't a thing it could really know about. So I hunted a new one.
They're all terrible.
Which was a huge problem, until I realized that the tools assisting me in my coding were also the right tools to categorize and analyze the sentiment of the music I was listening too! So rather than having Claude write it, I dove in and rewrote all the analysis code switching to ChatGPT's api and using the structured return and a relatively simple prompt to get what I needed back.
This was much messier before I discovered the formatted response tooling.
From there it was just cleaning up data transforms and formatting output. Oh, and breaking out some modules because the script was now pushing 400 lines of code, and files of that length and complexity are hard for me to reason about.
In the end it was probably 70% generative ai, and 30% my own code. There are patterns not typical to how I work in there. Not bad just different. There are inefficiencies in there. They don't really matter for this tool, for instance, the ChatGPT calls are impressively slow. It was a fun experiment in assisted coding, and a fast way to build out a simple tool that will get used for years to come.
Using algorithms to see what effects algorithms, some time well spent.
Oh yeah, here is the project if you want to use it. The readme is pretty good.
Footnotes
-
I am curious how this ends up affecting the algorithms they use. Partly because this feels like a strong source of learning for them. I am hoping it opens up some new recommendations for me, and helps avoid the pandora problem. The pandora problem being the convergence of all of your music into basically the same thing. ↩
If you enjoyed this article please share it! I also have a newsletter that you might enjoy as well. Thanks! -Daniel