How can I prioritize a release based on barcode or other field?


I have some albums that have barcode metadata that I wish to match to a musicbrainz release. However the Picard options doesn’t include any prioritization for metadata fields, only release type?

What is the correct processor/file hook I could use to match my album to one of the releases? My thought is to loop through the releases via register_album_metadata_processor. If so, what would be the function to set the file to match? Or should I just loop through all metadata fields and assign them to the file.metadata?


Can I clarify what you are actually asking to do here?

It looks like you want to wait until the release metadata + associated releases metadata have both been received from MusicBrainz, and then if one or more of the tracks on the album have an existing barcode tag, and if all the existing, non-empty barcode tags in all the files are the same, and if that barcode is not associated with the currently selected release, and if that barcode is associated with an alternative release then you want to select that alternative release (as if it had been done using the UI) and for Picard to then download the metadata for that alternative release from MB.

Is that correct?

I’ve been trying to do it per-track and only if there is a barcode match.
So if a track has “barcode”, get the release metatada + associated metadata, check it against the release “barcode”. If it is a match then associate the track.

The matching part seems straightforward ,I’m just doing a for loop over the release via


I’m not sure what function I should use to do the match though? Is it just a case of copying all the metadata/associated metadata fields into track.metadata from release?

I like your idea a lot! Not sure how I would execute that though. I was thinking that if my barcode match fails per track, then just fallback on the Picard default match.

looking a bit further into it, it looks like both the metadata processors only pass a single release match.


I’m guessing I need to influence what release is matched via a different processor?

Barcodes are provided for an Album or in MB a release. So doing this by track doesn’t seem to me to make much sense.

But before you choose which metadata_processor to use, you need to decide:

  1. What your algorithm is;
  2. Whether the metadata is album or track related
  3. Whether it is actually possible to do what you want from the metadata_processor you have chosen.

Unfortunately it is some years since I last wrote a plugin and my knowledge of the Picard internals has faded. If I had the time to research this inside the code, I could probably give a definitive answer, but I don’t so I will need to leave it to genuine experts like Philipp @outsidecontext to answer whether this is possible.

1 Like

Care needs to be used when trying to match the barcode to a release. The same barcode could match any number of releases within a release group. A release that has been re-released could even have some different tracks or track order but have the same barcode (not that many but I have some of them). A release from UK and the US could have the same barcode but a different catalog number.

Years back when I first started on MusicBrainz I thought I could match much of my collection using the barcode. I kept a catalog/DB with artist, album name, catalog#, barcode, purchase date, price and other information. I wrote a perl script to query the database and grab all the releases that matched my barcodes. About 1/5 of the queries got the correct result for an exact match. Another 1/5 produced a release for another country that I could use to create a new release. Another 1/5 produced multiple country matches where I had to decide which one was correct. Another 1/5 did not match but a manual search produced the correct release that did not have a barcode entered. The rest I had to create new releases. A very time consuming process and very manual.

I am pleased with the final catalog as it now includes the release MBID and discID. I encode the release MBID into the comment field on my cue sheets and cuetools fills the comment tag in when I convert the FLAC album into MP3 tracks.

This is a long way around of saying you will find the barcode may not achieve the result you are looking for.


There is currently no plugin hook to change the matching. The metadata processors get loaded for releases loaded on the right and their primary purpose is to provide a way to manipulate the loaded metadata.

If you want to lookup by barcode only remember that you can always do a manual lookup for the release. E.g. you can use the built-in search or search via the website. One starting point could be the “search for similar albums” action available for clusters, which already uses the barcode in the lookup search query.

If you instead want to do this by a plugin you could use the register_file_action or register_cluster_action hooks to register a context menu action that performs your own search via MB API for barcode and then loads a matching release.

Have a look at picard-plugins/ at lookupexperiments · phw/picard-plugins · GitHub which does provide alternative lookup actions using some experimental APIs from the ListenBrainz project. This could be a starting point.


Thanks for all the advice. I think I’ll try to do a context action to shortcut shortlisting the barcode matches to make it a bit quicker to do the manual matching. This alternative lookup actions looks like the piece I have been missing.
I’m not too comfortable with completely automatic tagging anyway, so knowing that multiple releases for a single barcodes can exist isn’t good!