KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'd like to be able to detect whether an audio file has embedded album art and, if not, add album art to that file. I'm using mutagen 1) Detecting album art. Is there a simpler method than this pseudo code: from mutagen import File audio = File('music.ext') test each of audio.pictures, audio['covr'] and audio['APIC:'] if doesn't raise an exception and isn't None, we found album art 2) I found this for embedding album art into an mp3 file: How do you embed album art into an MP3 using Python? How do I embed album art into other formats? EDIT: embed mp4 audio = MP4(filename) data = open(albumart, 'rb').read() covr = [] if albumart.endswith('png'): covr.append(MP4Cover(data, MP4Cover.FORMAT_PNG)) else: covr.append(MP4Cover(data, MP4Cover.FORMAT_JPEG)) audio.tags['covr'] = covr audio.save()
Tags (comma-separated)
Save Edits
Cancel