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 (Fron开发者_如何学Pythont Cover). Is there a way to do this in Python, specifically in Mutagen?
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!
精彩评论