Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change embedded image type in APIC ID3 tag via Mutagen

I have a large music library which I have just spent around 30 hours organizing. For some of the MP3 files, I embedded the cover art image as type 0 (Other) and I'd like to change it to type 3 (Front Cover). Is there a way to do this in Python, specifically in Mutagen?

like image 520
Naftuli Kay Avatar asked Feb 27 '23 22:02

Naftuli Kay


1 Answers

Here's how I was able to pull it off.

First, get access to the file in Mutagen:

audio = MP3("filename.mp3")

Then, get a reference to the tag you're looking for:

picturetag = audio.tags['APIC:Folder.jpg']

Then, modify the type attribute:

picturetag.type = 3

Then, assign it back into the audio file, just to be sure

audio.tags['APIC:Folder.jpg'] = picturetag

Finally, save it!

audio.save()

And you're there! The APIC tag comes with its own class that sports everything you'd need to modify pictures and picture tagging info. Happy music organizing!

like image 138
Naftuli Kay Avatar answered Mar 11 '23 06:03

Naftuli Kay