Search code examples
pythonmp3pydevid3mutagen

Python 3.8 Mutagen wont read GEOB tag


I'm using PyDev with Eclipse. Mutagen installed through Anaconda.

I have experience in C, but decided to give Python a shot. Not sure why this isn't working, and there's not a lot of examples for Mutagen. This is a simple mp3 that I'm trying to read a tag from. I checked the Mutagen spec and the GEOB class does exist. But I dont see what I'm missing.

Here is my python file:

import mutagen

from mutagen.id3 import ID3

audio = ID3("Test.mp3") #path: path to file

titleData = audio.get('TIT2')
print(titleData)

tagData = audio.get('GEOB')  # returns None as a default
print(tagData)
    
 
print("Done!")

Here is the output:

Stupid Song
None
Done!

I'm using a file Test.mp3 as my test case. And if I open with a hex editor, I see there is in fact a GEOB tag: Screenshot of 010 Editor

So I would expect to see an output other than 'None'. Any help is appreciated!

Update: Added the lines:

printall = audio.pprint()
print(printall)

and got the output:

GEOB=[unrepresentable data]
GEOB=[unrepresentable data]
GEOB=[unrepresentable data]
GEOB=[unrepresentable data]
GEOB=[unrepresentable data]
GEOB=[unrepresentable data]
GEOB=[unrepresentable data]
TBPM=142
TCON=Other
TIT2=Stupid Song
TKEY=E
TSSE=Lavf58.20.100
TXXX=SERATO_PLAYCOUNT=0

So am I just using the audio.get function incorrectly? I would like to be able to get all that [unrepresentable data] as binary, or hex.


Solution

  • Per the mutagen manual to get all the frames with a given identifier, the method call is "getall" not "get". The following method returns the song title and all GEOB frames.

    def get_tags_mutagen(filepath):
        audio = ID3(filepath) #path: path to file
        
        titleData = audio.getall('TIT2')
        print("Song Title: ", titleData)
    
        tagData = audio.getall('GEOB')  # returns None as a default
        for i in tagData:
            print(i)
    
        return tagData