A module that can be used to get a user's LastFM recent song(s) along with other data and send it over a websocket connection. This can be useful for realtime status updates on a website, or OBS overlays for streaming.
ws://localhost:3621/fm/USERNAME
{
"artist": "Grant",
"track": "Wishes",
"image_url": "https://lastfm.freetls.fastly.net/i/u/174s/5bb0cf2d5c308fb4df40e6aab7514d4d.jpg",
"track_url": "https://www.last.fm/music/Grant/_/Wishes",
"is_now_playing": true
}
The response will default to return the current played song or the most last played song if the user is not currently playing anything. This will be indicated by the is_now_playing
field defaulting to true if the user is currently playing something.
This solution polls LastFM every 2 seconds for an update. LastFM isnt exactly specific on their hard rate limits but it should be fine for personal use.
It is possible to run an instance using Docker. I highly recommend using Docker compose. Check the example config and customize it to your needs.