XSL to get Album Artist Credit Name from Release Details metadata XML file?

HI, folks:

I have a collection of tagged music files in a directory tree. It has a separate directory for each Release, with the music files and a copy of the MusicBrainz metadata XML file for that Release. The metadata is what you get from the Details tab of a Release page.

I now want to write a script to restructure this directory tree, using artist credit names from the Release Details metadata file. I plan to use an XSL stylesheet to get the artist credit name out of the XML file.

But what the XML file actually contains is the pieces of a name credit, not the whole string: an <artist-credit> element, containing a sequence of <name-credit> elements, each with a joinphrase attribute and an <artist> subelement. Some older metadata files skip the <artist-credit> and <name-credit> elements, and go directly to an <artist> element

I think I can write the XSL to put these parts together into a name credit string, but I would rather re-use work which someone has already built, tested, and shared.

Can anyone point me to a freely-reusable XSL stylesheet which generates an artist name credit string from the parts in a MusicBrainz Release metadata XML file?

I have searched this forum, and the MusicBrainz wiki, and the Metabrainz Github collection, and I don’t find it there. Thank you in advance for any leads.

[Updated to move into the “Development” subcategory, rather than “MusicBrainz” generally. —JDLH]

Depending on your desired directory structure, you might be able to achieve this a lot easier by using a custom file naming script in Picard.

Good point. Picard is a flexible tool.

However, to my understanding is that Picard won’t move files without putting tags in them first. These music files are raw from ripping, without yet having a proper set of tags. I want to treat these files as archives. I don’t want to change their contents. I just want to move them.

You can actually disable writing tags to files. See the configuration settings in Tag Options — MusicBrainz Picard v2.11 documentation for more information. Of course, if you do decide to give this a try, I strongly suggest that you initially try it on a copy of some of your files to make sure that it’s not making unwanted changes.

2 Likes

Thank you for telling me that. I did not know that Picard could restrain itself like that.

I forgot about the other difficulty: I want to use metadata from a MusicBrainz metadata XML file in the same directory as the music files. Do you know if Picard can operate on metadata from an xml file instead of from the MusicBrainz database?

I suppose I could use a workaround: have Picard read an audio fingerprint from the music files, use that to look up the correct Release on the server, then create directory names based on that Release on the server.

It’s not XSL, but it is perhaps less work overall. Interesting.

The xml file probably contains the MBID for the release,so you could use that to look up the information. You could even use a command line argument to load it, so might be able to automate the process somewhat. Have a look at Command and Batch Processing — MusicBrainz Picard v2.11 documentation for more information.

3 Likes