Skip to content Skip to sidebar Skip to footer

Python Mutagen: Add Cover Photo/album Art By Url?

Using mutagen, I am able to add normal metatags such as title, artist, and genre however when I try to add an image via a url, it doesn't work. from mutagen.mp4 import MP4 from mut

Solution 1:

This works for me:

fd = urllib.urlopen(cover)
# Drop the entire PIL part
covr = MP4Cover(fd.read(), getattr(
            MP4Cover,
            'FORMAT_PNG' if cover.endswith('png') else 'FORMAT_JPEG'
        ))
fd.close() # always a good thing to do

audio['covr'] = [covr] # make sure it's a list
audio.save()

Post a Comment for "Python Mutagen: Add Cover Photo/album Art By Url?"