Handling of multiple release countries with Picard 2.3.1

Tags: #<Tag:0x00007f7571151218> #<Tag:0x00007f7571150ea8>

Recently there has been quite some debate about some digital releases with a really long list of release countries added. Independent on your stand on this matter, this has shown that there are some issues with how these releases are handled by Picard. Hence the current Picard 2.3.1 release attempts to make some improvements.

Let’s take the following release as an example.

By default Picard will write a single releasecountry tag to the files. So far Picard has been populating the tag with what the MusicBrainz server returns as the country for the release. If there are multiple release events this country field is just filled with the first one in alphabetical order (Algeria in the example). But Picard 2.3.1 offers you some options to handle it better.

Using preferred release countries

The first improvement is automatic if you have configured preferred release countries in Options > Metadata > Preferred Releases. Picard will use the first country from the preferred release countries that is also in the list of release events. So for example I have configured preferred release countries to be Europe, Germany, UK. For the above example that would mean releasecountry gets set to Germany.

Using scripting to set a different country

Picard 2.3.1 provides a new variable %_releasecountries%, which provides the complete list of release countries for a release. You can use this to set different values for releasecountry.

For example the following script would set it to “[International]” if there are 10 release countries or more:

$if($gte($lenmulti(%_releasecountries%),10),$set(releasecountry,[International]))

Of course you can adjust the count and the replacement text to your liking. You can also choose to save the entire list instead of just a single country to this tag:

$setmulti(releasecountry,%_releasecountries%)

Or maybe limit this list to the first entries. The following example just uses the first 6 countries:

$setmulti(releasecountry,$slice(%_releasecountries%,0,6))

What’s missing?

Countries are currently written to the tags as their ISO 3166-1 country code, with some special values added for historical countries and things like [Europe] or [Worldwide]. These codes are not always easily recognizable, e.g. that DZ is Algeria or DE is Germany might not be obvious to you. You can of course use scripting to make this more redable, e.g. if you want to see “United Kingdom” instead of “GB” in this tag use:

$if($eq(%releasecountry%,GB),$set(releasecountry,United Kingdom))

This might work if you deal only with a couple of countries in your collection. Or you just want to handle some special cases like using “Europe” instead of “XE”, e.g. I use the following script:

$if($eq(%releasecountry%,XE),$set(releasecountry,Europe))
$if($eq(%releasecountry%,XU),$set(releasecountry,[Unknown]))
$if($eq(%releasecountry%,XW),$set(releasecountry,[Worldwide]))
$if($eq(%releasecountry%,XG),$set(releasecountry,DDR))

But I actually would like to see some helper functions for this, e.g. there could be a $countryname() function one can use to easily convert the code into a readable name.

8 Likes

I could try to come up with something similar to the $language_name plugin that I wrote to return language information. There is a User Guide for the plugin, and the plugin and source code are available for download on GitHub. This could also provide a starting point if anyone else wanted to try developing something.

1 Like

This needs a louder WOO! YAY! and Thanks! :partying_face: :partying_face: :partying_face:

I hadn’t even spotted the confused countries before, but realise I have many albums over the years that are therefore missing “correct” country info due to the one country limit.

Excellent job on a neat solution there.

1 Like

Exactly same situation for myself actually, except that I think for my previously tagged files it was never a big issue. Most probably had one country set, or maybe there were two or three, mostly probably listing UK or Germany.

But now with the band camp and other digital releases it has become annoying. I was very happy when I realized this can be improved with rather simple changes :slight_smile:

3 Likes