When submitting to ListenBrainz existing MusicBrainz IDs for the recording, release and artist should be included, if they are available from the files. This way ListenBrainz can exactly identify the played tracks and will link them accordingly.
I have this implemented now (For ID3v2, Vorbis and APEv2). Looks like this is working since I'm now getting blue links in the profile on tracks that have the data.
When submitting to ListenBrainz existing MusicBrainz IDs for the recording, release and artist should be included, if they are available from the files. This way ListenBrainz can exactly identify the played tracks and will link them accordingly.
See docs at https://listenbrainz.readthedocs.io/en/production/dev/json.html#payload-json-details
You can also take a look at the implementation at https://github.com/phw/rhythmbox-plugin-listenbrainz/blob/master/listenbrainz/client.py and re-use this or parts of it. It also handles rate limiting.
I tried to make this ListenBrainz client class as universal as possible to allow reuse (and possible release it separately). So far it has been reused at https://github.com/ijc/quodlibet-listenbrainz-plugin/blob/master/listenbrainz.py and was originally derived from code written for the Lollypop player.