It's been a few months since I shared how I had integrated (near) realtime weather station data[1] into my omg.lol profile page[2]. I've since done a little bit more work to start managing that (and the related /now[3] page) with GitOps[4]. Not only has that allowed me to update my pages from my terminal, but it's also made it easier (and safer) for me to tinker with the presentation.
So today I knocked out something I'd been intended to do for ages: I set up my /now page to pull the latest album or track from my "Now Playing" thread on MusicThread[1]. I opted for this approach rather than direct last.fm (or other scrobbler) integration for two important reasons:
I want it to answer the question, "Hey, what are you listening to lately?" rather than just blindly reporting whatever happens to be queued up. As a visitor to someone's page, I'm less interested in what song is currently playing than I am in what music has caught their ear recently. So that's what I wanted to present on my page.
All that is to say, this integration was pretty straight forward and I didn't even need to mess with any messy authentication. MusicThread has a very simple API[1], so I quickly determine that all I needed to do was make a `GET` request against:
I'm only interested in the newest (0th) entry, and I only need the title, artist, and page\_url. So here's the JS I hastily threw together to throw into the head element of my web/now page:
So that's now live on now.jbowdre.lol[1], and the source for the whole shebang is in my GitHub[2]. I even have a quick musicthread.html[3]page I made for testing in case you want a quick peak at just this piece.