Using Picard File Object with Non-Plugin Script

Tags: #<Tag:0x00007f0768d14770> #<Tag:0x00007f0768d142c0> #<Tag:0x00007f0768d14068> #<Tag:0x00007f0768d27e10> #<Tag:0x00007f0768d27c58>


Hello everyone,

I am in the midst of writing a Python script (not a Picard plugin, but just a script) to handle some niche parts of my music library and I would like to try using Picard’s metadata system if possible.

I am quite familiar with Mutagen (which I believe Picard uses to handle metadata). Using Mutagen I have created a generalized dictionary form for handling the most common tags in ID3, VoribisComment, etc. My problem is that when I use Musicbrainz to do my initial tagging, it seems that there are many more tags which I would be overlooking using my solution. So rather than writing handlers for every obscure tag, I was wondering if I could simply use Picard’s metadata object inside of my own script.

I have not looked too deep into the Musicbrainz source code quite yet. What I have tried is importing the formats module and using the open_() function, but it seems like this is not the correct way to go about it.

>>> from picard import formats 
>>> formats.open_('The Menzingers - On The Impossible Past - 02 Burn After Writing.flac')
E: 12:41:39,295 /usr/lib/python3.6/site-packages/picard/formats/__init__.open_:87: Error occurred:
'NoneType' object is not subscriptable

What I’m looking for is a generalized tag object which I can pass a file path in my script, and will allow me to handle basically any popular tagging format. I figure this is probably built-in to Picard somewhere, but I’m not entirely sure where to look or as to whether it would be as simple as importing and using directly in my own scripts. But I’m hoping that it is!

Thanks in advance.