The Apps API supports WebSockets just fine, so you can write a server application that you run on localhost
and have your Spotify App connect to it. Or, you could skip sockets and write a little REST API to run on localhost
that your Spotify App calls with the relevant details every time a song changes.
However, be aware that Spotify Apps don't run forever. If your app isn't visible on-screen (say, if you've navigated elsewhere in Spotify), it'll get suspended after a few minutes.