Eavesdrop.FM: Sync Plex Music listens to ListenBrainz

100% agree! I’ve got an open issue tracking this here:

The tl;dr is that I’d love to be able to, but at the moment, webhooks from Plex don’t provide enough information about the library for us to do this. I’ve raised an issue internally with Plex though, so hopefully we’ll be able to do something about this soon :slight_smile:

@aubrey.wodonga

Thanks for this project! It works wonderful.

I had a question. Are you able to submit the mbids via the webhooks? Otherwise how does this work? Because listenbrainz requires the mbids does it not?

1 Like

Hi @d2freak, I’m glad you’re enjoying it :slightly_smiling_face:

Unfortunately webhooks don’t provide MBIDs in the payload, they provide Plex GUIDs. As far as I’m aware, there’s no trivial way (or even any way at all, really) to map these GUIDs to an MBID. Thankfully ListenBrainz doesn’t require MBIDs, they’re an optional field. API docs can be found here:

https://listenbrainz.readthedocs.io/en/production/dev/json/#submission-json

It’s definitely something I’d like to be able to do one day though. In the interim, MetaBrainz have been working hard on linking un-matched data to MusicBrainz entities, and from what I’ve seen, this works pretty well!

That’s why features like their new “tracks you might like” work despite missing MBIDs in all the Plex submissions. If you haven’t already, you should check that feature out by the way!

https://listenbrainz.org/recommended/tracks/SimonXCIV

2 Likes

Thanks for the link to the api doc. That was interesting. What exact fields are you able to send using the webhook method?

I’m imagining that if you are able to send for example the track number, identification on the MusicBrainz side would be quite a bit more reliable.

About ListenBrainz doing their own matching to mbids - okay, I’m new to ListenBrainz so I didn’t know this. But, I must say, I’m a bit confused about this. If ListenBrainz does some matching, how come the scrobbles from Plex is not showing up as clickable? As far as I’ve seen, users who scrobble with mbids have the artist/release/recording clickable.

This is not just cosmetic - ListenBrainz seem to separate artists with a featured second artist because of this. I mean that it sees “A feat. B” as a separate artists than “A”

This is the same problem last.fm has. I thought ListenBrainz could finally be a solution to this, but now I’m not sure. But maybe I’m misunderstanding something?

I’m glad I could help :slight_smile:

There’s a (surprising) amount to unpack in your questions, so let me try and answer as best I can!

ListenBrainz uses another MetaBrainz service called “MessyBrainz” to associate unlinked (messy) listens with an “MSID”, which is like a linking identifier. You can read more about it here:

So because a messy listen isn’t really linked to an mbid, you don’t see the links to the artist/recording, but they’re able to translate an msid to an mbid and provide recommendations for example.


The primary issue here is on the Plex side, not necessarily the last.fm or listenBrainz sides, and there’s actually two issues:

  1. Plex doesn’t have any concept of track artist, only album artist
  2. Plex only handles 1:1 artist relationships (with albums), so split EPs for example would be under a single artist named A and B, rather than under both A and B

As a workaround, handily in the webhook payload they send a text string that contains the track artist title. Unfortunately, this isn’t an actual artist entity (or list of artist entities), it’s just a string of text, so a feat. b is just one long string, not individual artists.

In my code, I’m handling this like so:

"artist_name": body.Metadata.originalTitle ? body.Metadata.originalTitle : body.Metadata.grandparentTitle

This basically says if there’s a track artist (originalTitle), send that, if not, send the album artist (grandparentTitle).

So to get where you’re asking, there are a few things that Plex would need to change:

  1. Allow tracks to have artist relationships
  2. Allow more than a 1:1 relationship between track > artist (and album > album artist)
  3. Send all of the above in the webhook payload, including an array of track artists where they exist (e.g. feat.)

Here’s a rough example of what we get from a Plex webhook (from the docs):

{  
   "event": "media.play",
   "user": true,
   "owner": true,
   "Account": {
      "id": 1,
      "thumb": "https://plex.tv/users/1022b120ffbaa/avatar?c=1465525047",
      "title": "elan"
   },
   "Server": {
      "title": "Office",
      "uuid": "54664a3d8acc39983675640ec9ce00b70af9cc36"
   },
   "Player": {
      "local": true,
      "publicAddress": "200.200.200.200",
      "title": "Plex Web (Safari)",
      "uuid": "r6yfkdnfggbh2bdnvkffwbms"
   },
   "Metadata": {
      "librarySectionType": "artist",
      "ratingKey": "1936545",
      "key": "/library/metadata/1936545",
      "parentRatingKey": "1936544",
      "grandparentRatingKey": "1936543",
      "guid": "com.plexapp.agents.plexmusic://gracenote/track/7572499-91016293BE6BF7F1AB2F848F736E74E5/7572500-3CBAE310D4F3E66C285E104A1458B272?lang=en",
      "librarySectionID": 1224,
      "type": "track",
      "title": "Love The One You're With",
      "grandparentKey": "/library/metadata/1936543",
      "parentKey": "/library/metadata/1936544",
      "grandparentTitle": "Stephen Stills",
      "parentTitle": "Stephen Stills",
      "summary": "",
      "index": 1,
      "parentIndex": 1,
      "ratingCount": 6794,
      "thumb": "/library/metadata/1936544/thumb/1432897518",
      "art": "/library/metadata/1936543/art/1485951497",
      "parentThumb": "/library/metadata/1936544/thumb/1432897518",
      "grandparentThumb": "/library/metadata/1936543/thumb/1485951497",
      "grandparentArt": "/library/metadata/1936543/art/1485951497",
      "addedAt": 1000396126,
      "updatedAt": 1432897518
   }
}

I’m suspecting the index in the payload above might actually be the track’s position on an album in Plex, so I might be able to send that as the trackNumber, but I’m not sure that would be wise. If users have missing tracks in albums, for example, the index may not be an accurate track number, and could actually make matching worse. IMO no data is better than bad data for this sort of thing.

Hopefully I’ve been able to answer your questions, and thanks for all the thought you’ve given it. I really appreciate the feedback and ideas!

2 Likes

Just used your eavesdrop website to get my listenbrainz set up. Very easy, very straight forward. So Far everything seems fine. Thanks for this fun and interesting project.

2 Likes

Thanks for the very in depth answer! I really appreciate that.

It’s a shame then that even after they match the messy info to a mbid that they don’t display it as such on the webpage. Kind of like an autocorrect of sorts. That is what threw me off.

About the limitations of Plex - wouldn’t it be enough if they could expose the recording mbid and the release mbid and you flat out just send that? Or am I misunderstanding now? I’m thinking if those two mbids are sent, ListenBrainz could bypass MessyBrainz entirely and just scrobble/display the info for that specific recording, even without any other specific information at all. I’m thinking that as long as that info is present, the specific track artist name or even id is not required.

In an ideal world, it would be great to be able to send MBIDs directly, agreed.

At this time though, MBIDs aren’t included in webhook payloads, so for now there’s not much we can do about it. I’ve requested the feature, but to my understanding it’s not currently on the roadmap. If Plex decides to implement this, you can be sure I’ll jump on it quickly and make the required changes for Eavesdrop.FM to take advantage of it :wink:

2 Likes

Appears to not be working today?

Not sure if it’s an issue with the webhook or ListenBrainz.

EDIT: Must have been ListenBrainz. Working now, and listens are all there!

1 Like

Thanks for the heads up, I’m not sure what was happening there, but it seems to be fine for me this morning, too.

Hi all,

I’ve updated eavesdrop.fm today to take advantage of the new librarySectionTitle webhook payload field introduced in Plex Media Server 1.20.5.

During the setup flow, you’ll now (optionally) be able to exclude libraries from submitting data to ListenBrainz. This was requested primarily for users that have audiobook libraries using the Music library type. Simply add your library names to the exclusion list, separated by commas, and we’ll ignore any webhook events from these libraries. Make sure you’re using PMS 1.20.5 or later!

Let me know if you have any questions :slight_smile:

2 Likes

Hi @Quasar,

Check out today’s update. If you reconfigure your webhook now, you should be able to filter out the libraries you don’t wish to submit to ListenBrainz.

Thanks so much! I just finished my 3rd audiobook so this couldn’t have come at a better time!

1 Like

I just dumped last.fm for this + listenbrainz. Imported all my last.fm listens to listenbrainz, set up your webhook on my plex server, and verified it was sending my listens to listenbrainz. So far, it’s working great! Great job!

2 Likes

Hi all, another quick update today with two bug fixes:

  • Properly handle usernames that contain spaces.
  • Catch webhook events that don’t contain media Metadata, such as new device login events. This should reduce 500 errors.
1 Like

Thanks for solving my issue :slight_smile:

Now I just have to try and clean up my listening history

1 Like

Thanks for this! I’m going to try it out. I assume it works fine with Plexamp?

2 Likes

Yes, works without issue. There are some slight hiccups with TIDAL content, but that is more of a Plex problem (with PMS specifically), I think.

3 Likes

it should work with any plex client, as it is the server which sends the listen to listenbrainz.

1 Like

Thanks. I’m using it and it seems to be working well with PlexAmp. Thanks for building this @aubrey.wodonga!

1 Like