1

I am working on an algorithm that uses AcousticBrainz API. Part of the process is assigning an audio file with a specific UUID that refers to a file in a database. The tag is added via Picard and is present among other tags when checking e.g. via VLC Media Player:

enter image description here

Is there any way to access these 'custom' tags? I tried to use eyeD3 and mutagen, however, I think they only enable accessing specific tags like artist or length of the file.

Can I use eyed3 or mutagen to accomplish the goal? Is there any other tool that enables such operation?

fasola
  • 47
  • 3

2 Answers2

1

Yes, you can use either one. These custom tags are stored as user text frames, with the frame ID "TXXX".

Here's some example code with eyeD3:

import eyed3

file = eyed3.load("test.mp3")
for frame in file.tag.frameiter(["TXXX"]):
    print(f"{frame.description}: {frame.text}")
# get a specific tag
artist_id = file.tag.user_text_frames.get("MusicBrainz Artist Id").text

And with mutagen (it supports multiple values in each frame, but this seems to violates the ID3 spec; see this picard PR for the gory details):

from mutagen.id3 import ID3

audio = ID3("test.mp3")
for frame in audio.getall("TXXX"):
    print(f"{frame.desc}: {frame.text}")
# get a specific tag
artist_id = audio["TXXX:MusicBrainz Artist Id"].text[0]

You can see how Picard uses mutagen to read these tags here: https://github.com/metabrainz/picard/blob/ee06ed20f3b6ec17d16292045724921773dde597/picard/formats/id3.py#L314-L336

yut23
  • 2,624
  • 10
  • 18
0

Thank you Eric Johnson! I was unaware of the different tag formats. I was interested in accessing the MBID of the recording and I could not get it through ID3, however, your example and reference to Picard really helped. I ended up needing to read UFID tag, so I used the following:

audio = ID3(filepath)
for frame in audio.getall("UFID"):
    print(str(frame.data, 'utf-8'))

Posting it here in case anyone needs it in the future.

fasola
  • 47
  • 3