Album names in Picard

Does anyone know how Picard gets the album name to display in the top right hand panel (i.e. the album name under which the tracks are listed)?
I want to modify the album names with a script (to add composer names). If I do this, then the album tags are all modified for each track as expected, but the album name in the panel is eliminated altogether. It seems that Picard doesn’t like that I’ve chosen a different album name for the tags than the one in MB. I’d like to fool it into thinking they are the same, but can’t see how to do this. I tried modifying the _releasegroup variable, but that doesn’t seem to fix it.
Any ideas?

Modifying the album tag should work. What exactly are you doing? Please show us your script and the releases you load.

My current suspicion would be that you are using variables that are available per track, but not for the album itself.

I have a plugin which creates a hidden variable _cea_album_composer_lastnames. The script is then:

$set(release_name,%album%)
$set(album,$if(%_cea_album_composer_lastnames%,$if($not($in(%album%,%_cea_album_composer_lastnames%)),%_cea_album_composer_lastnames%: %album%)))

This sets the album tag correctly, but loses any album name in the right panel.

Your script sets the album variable to some value if _cea_album_composer_lastnames is set and the _cea_album_composer_lastnames is not already part of album. In all other cases it sets album to be empty. I suppose _cea_album_composer_lastnames is empty in your case.

Have a look at the definition of $if:

$if(if,then,else)

If if is not empty, it returns then, otherwise it returns else.

If you don’t specify anything for else it will just be empty. So to set some variable if the condition is met and keep it as is otherwise use:

$set(album,$if(%_cea_album_composer_lastnames%,%_cea_album_composer_lastnames%: %album%,%album%))

Your complete example should maybe look like this:

$set(album,$if($and(%_cea_album_composer_lastnames%,$not($in(%album%,%_cea_album_composer_lastnames%))),%_cea_album_composer_lastnames%: %album%,%album%))
1 Like

That’s not the problem (although you are correct to add the extra term). %_cea_album_composer_lastnames% is not empty and album is set correctly. The issue is that the album name (neither the new one nor the original) is not displayed in the right hand [panel.

The title is not displayed because album gets set to an empty value with your script. I can reproduce this with your script, as soon as your​ variable is empty the album title gets cleared. The fixed script I posted above always will set a value. For me this works in Picard, please try.

And yes, I am pretty sure the variable is empty for the album. Please double check this and post your plugin code if in doubt.

1 Like

Many thanks for the help. There’s something a bit subtle here that I don’t understand (maybe being thick!).
With the code that I quoted, the script was correctly setting the album tag for all tracks, but the album title did not appear in the right hand panel.
So I tried a very simple script with no plugins:
$set(album,my_prefix:%album%)
This worked fine - set the album tag and appeared in the panel as "my_prefix:…"
I then realised that there were two $if statements in the original script and that I had only added the “then” condition for one of then. So I added the other:

$set(album,$if(%_cea_album_composer_lastnames%,$if($not($in(%album%,%_cea_album_composer_lastnames%)),%_cea_album_composer_lastnames%: %album%,%album%),%album%))

This not only set the album tags but also put the album title in the right hand panel, but it was the original title, not the one in the tag (in contrast to the “my_prefix” example above.
So it seems Picard was happy to change the name in the panel when it was a simple $set, but not happy with my conditional $set, so it was looking for the alternative which I had not supplied. Odd, but the result is OK. :confused:

I can’t fully explain this without looking at the plugin code that sets this variable. But it will come down to the fact that it uses the composer name, which is set on the work level. So it is available as information per track, but not on the album. Picard runs the script separately for each track and for the album itself.

In the plugin you can have both a track_metadata_processor and an album_metadata_processor, I think in this case you should use the latter.

1 Like

Very helpful, thanks! I can see from experimentation that the variable needs to be set by album_metadata_processor. I must admit that, being new to Picard, I find the documentation of the API to be very sparse, so help like this is most welcome.
So I tried to fix the plugin by adding an album_metadata_processor. This needs to run after the track_metadata_processor as it needs to work out which of the album artists are actually composers (only available at track level) before applying the result to the whole album.
However, the album_metadata_processor always seems to run first whatever I try, so the results of track_metadata_processor are never available to it. I’ve tried various hacks to get them in the right order, but it seems that asynchronicity rules OK.

You can’t set the order of the processors running, the album_metadata_processor will always run first. But you can access the album inside the track_metadata_processor with track.album and also update the metadata there.

2 Likes

Still head-scratching on this. I’d already tried album.metadata with no success, but track.album.metadata doesn’t seem to work either. Code snippet is:

    def process_album(self, album):
	for track in self.track_listing:
	tm = track.metadata
	if self.album_artists[album]['composer_lastnames']:
		tm['~cea_album_composer_lastnames'] = self.album_artists[album]['composer_lastnames']
		track.album.metadata['~cea_album_composer_lastnames'] = self.album_artists[album]['composer_lastnames']

The track metadata is set OK, but not the album metadata. More precisely, an attribute track.album.metadata['~cea_album_composer_lastnames'] is set but it is not part of the album metadata and has no effect.

Please post the entire plugin

Plugin (still in development, but pretty stable) can be viewed at https://github.com/MetaTunes/picard-plugins/commit/8d24cd141e4c9e325afbbae6aece3a565312e65c
The failure to set the album title in Picard is not really a problem since at least it defaults to the original album name. NB most of the tags are written as hidden variables to be used by scripts.The code snippet above is from lines 467-473.

Documentation added - see the readme at https://github.com/MetaTunes/picard-plugins/tree/master/plugins/classical_extras

1 Like