ndzn / lastfm-websocket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LastFM to Websocket

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.

Requesting data

ws://localhost:3621/fm/USERNAME

Example JSON response

{
  "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.

Running

Docker

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.

About


Languages

Language:Go 97.8%Language:Dockerfile 2.2%