Showing a user's ListenBrainz listens in their Discourse community profile

I had some fun with the Discourse plugin API over the weekend and put together a small plugin that would allow users to show their most recent ListenBrainz listen in their discourse profile. For those who do not know, Discourse is the software powering these forums. Here is a screenshot on how it currently looks like:

Bildschirmfoto vom 2023-01-29 22-48-17

Currently this allows users to enable this functionality in their Discourse profile preferences and the plugin will either show their “now playing” track or the most recent listen if it is not older than a configurable time (defaults to 24 hours, but users can change that). The listen is shown in a similar style to how it is on LB, and there is a button that let other users open the “Play on ListenBrainz” page.

This is all work in progress and I have some ideas on how to extend this. So far this has been only a fun project for me to get to know Discourse capabilities better.

I am willing to make this into something useful if there is a) some interest here in the community and b) @Freso and @Zas would be interested into including such a plugin in the MB community Discourse setup.

So let me know, is this something you would like to see in MB community? If yes, what features would you expect exactly? Would you actually use it?

For those interested in the actual plugin, the current source is available at ~phw/discourse-listenbrainz - sourcehut git


So cool!

I don’t know if I would necessarily need more. Maybe a button to the users profile next to the play button. Could go crazy with other stats but this seems nice and straightforward.
Edit: Maybe some text somewhere saying “last played:”

P.S. If there’s an easy way to do this for Discord and/or OBS Studio that would satisfy a sh*t ton of online requests/searches :smiley:

1 Like

I don’t know if I would necessarily need more.

Me neither. And actually I would not want to make this too complex in either way, more along of smaller suggestions like yours.

What I definitely wanted to have is a short profile view showing some basic data about the user profile as an alternative to the recent listen. This this currently looks like:


The time range to use for the data would be configurable. The bars in the background show the listening activity over this time frame.

P.S. If there’s an easy way to do this for Discord and/or OBS Studio that would satisfy a sh*t ton of online requests/searches :smiley:

No idea about those as I’m using neither actively. Maybe someone gets inspired to do something for these, but definitely not me. Outside my interests and enough on my plate already :slight_smile: And regarding Discord I don’t do open source work for closed source software out of principle, at least not unpayed :smiley: (and yes, there have been exceptions).


Ok friends of ListenBrainz, I did the changes I had in mind for a first working version.

The user can now choose between two different display options: Most recent listens and user profile statistics.

The most recent listens display is the default. It shows either the currently playing track or the most recent listened to track. If currently playing, a small notes icon is displayed. It will only show the most recent listen up to a specific age in hours, anything played earlier would not be displayed and hidden. The user can configure this. Example:


The user profile statistics show a few details for the user profile over a certain period of time (by default the last 30 days). It shows the total listen count, a cover collage of top releases, the most listened to track and a background bar chart of listening activity. Example:


The user can in their profile preferences choose between the time ranges last 7 days, last 30 days (default), last year and all time.

This is how the user preferences look like:


Not really sure about the options, but it seemed to work for me and give the users a bit of control what to display.

That’s it for now. I won’t do any further changes on this unless this plugin will actually get used. @zas what’s your take on this? EDIT: Just read the news about Freso’s absence for some time, so let’s not bother him.


This is sooo cool! Yes please to adding it @Zas!


We could add it of course (but that’s another plugin to maintain).
@reosarevok what do you think?

1 Like

Just wanted to write down some of my motivation to write this plugin (in addition to the technical interest, but this could have been satisfied with some other topic):

  • I consider ListenBrainz the currently most interesting MetaBrainz project with the most potential. I think it is something that is turning into a useful tool that makes digital music interesting. As such it can drive new users to contribute to the MusicBrainz database. In the age of CD ripping and file sharing taggers like Picard motivated users to contribute *), LB can take a similar role in the time of streaming music. Hence I consider it useful to cross-link it with the rest of the MetaBrainz world.

  • ListenBrainz is the most social MetaBrainz project, and the forums here are one of the important social platforms for the community (the other being IRC). Giving people the ability to cross-link can benefit the community.

  • We all here have different musical tastes. But I think what unites the MB community is a love for music, a certain obsession with organizing and documenting music metadata, and in many cases a quite broad and open minded taste for music. I’m sure the primary topics of discussion here will stay around the technicality of MB metadata and tagging, but I also welcome all discussions that are more about the music, like the recent MusicBrainz Album Club initiative. Bringing projects like CritiqueBrainz and ListenBrainz closer to the community can help making this part of the community more active.

That’s just my motivation. In the end I understand of course concerns about maintaining the Discourse setup, and if it’s chosen to not install this plugin I’m absolutely fine with that. But personally I’d love to see this functionality added and I’m definitely willing to maintain this plugin and tackle any issues that might come with new Discourse releases, just as I do with the MB onebox plugin. Discourse is rather stable here so I don’t expect much work. And if there is too much trouble this plugin can be turned off (temporarily or forever) without a big impact on the forums as a whole.

*) And still does, of course. Don’t worry here, I’ll keep using and developing for Picard


I’m fine with adding this, and just removing it again if it gets unmaintained and starts causing issues. Is there a way for users to opt out if they do not want to share their listening with the forum so directly?


They need to opt-in, see the settings screenshot above.


Then it seems perfectly fine to me :slight_smile:


@zas Shall we move forward with this then? I’ve been testing the plugin locally now for a while with different browsers, different themes and different states on LB and things are working as I intended. So from my side this is all good for a production deployment.

1 Like

I installed the plugin, so users can now go to their Preferences to enable it if they want.

1 Like

And found a bug when users have a non-English locale configured in Discourse :frowning: Sorry for that. I’m getting this fixed ASAP.


@Zas I updated the plugin. There was an exception thrown when users opened their profile preferences if they had set their Discourse language to anything else but English. This is now fixed. Sorry for the trouble.

Also, could you tick the option " listenbrainz username matches discourse" in Discourse Admin > Plug-ins > listenbrainz? That will make the username default to the Discourse username, so users in most cases don’t have to enter the name again. I added this specifically for the use case here in the forums.


Upgrade done, and option enabled.


Thanks a lot, that worked :slight_smile: I’ll do a separate post about this feature tomorrow to explain it to users and give it some place to discuss it from the users perspective.


Thank you so much @outsidecontext !
I missed this thread and just discovered the new feature yesterday and was truly surprised!
I love the feature, I think it’s a great fit for this specific forum, and I love the symbol it represents of more integrations to come between LB and other social websites people use.

It takes me way back to automated bulletin board signatures :slight_smile:

The one thing I could think of as an improvement would be showing when the listen was listened to.
Following the design on LB you could add that date string on the right hand side.

Quick mockup:

And for what it’s worth, if it’s of any use, here’s the function we use to display the listen time in LB:


@mr_monkey Good suggestion. I added this to my development branch. Needs a bit more testing. For the display I can use the function provided by Discourse. It has pretty similar functionality to the LB code for displaying the time ago, so it should give mostly the same result, and it will be consistent how Discourse displays those relative dates elsewhere.

1 Like

FYI, the profile statistics view has a very low contrast in dark mode (even lower than in light mode) which makes the bars hardly visible:

Is this intended or did you just not test the extension in dark mode?

Rather low contrast here is intentional, as the background is supposed to have a high contrast against the foreground so the text stays readable. On my monitors the bars are rather good visible.

The colors also come from the theme, so it’s expected that it varies. That also means I need to find some balance that works across themes.

I could choose the next brighter color, but I find it harms the readability of the foreground text. Below is how the brighter color would work across all of the Discourse default themes:

In comparison this is the current color setting (which I prefer):