Last.fm to mqtt

Clone this source
Last.fm to mqtt

I have been working on a photo-display project that will showcase photos and album art. In order to accomplish this, I needed to extract album art from the music that is currently playing. I decided to gather this information from Last.fm it is a reliable source that combines multiple sources of information.

The project pulls recent tracks from Last.fm and distributes the information through MQTT and WebSocket. I have also created a small browser application to display the currently playing track, artist, album, and album art.

I’m building a photo-display that will show photos and album art. For that reason I needed to extract album art from what I’m playing. Since there is multiple sources this could be gathered from Last.fm is joining these sources together.

This projects pulls recent tracks from Last.fm and distributes it to MQTT and WebSocket. A small browser app to show what’s playing now.

Mqtt payload

The payload sent through MQTT is in JSON format, and includes the following information:

Track: The name of the currently playing track

Artist: The name of the artist of the currently playing track

Album: The name of the album of the currently playing track

Now Playing: A boolean value indicating whether the track is currently playing

MBID: The MusicBrainz ID of the currently playing track

Image: A URL linking to the album art of the currently playing track

{
  "track": "I Sat by the Ocean",
  "artist": "Queens of the Stone Age",
  "album": "...Like Clockwork",
  "nowPlaying": true,
  "mbid": "3d07181c-afe8-4f36-8526-bbee50b98a36",
  "image": "https://lastfm.freetls.fastly.net/i/u/300x300/9872bc77018f9ba97f4bf504e25e1380.png"
}

If you are interested in this project, you can find the code on GitHub or read my notes here.