python - mutagen: how to detect and embed album art in mp3, flac and mp4 -


I want to find out if album art is embedded in an audio file and if not, then want to add album art That file is using the mutation

1) Is the album art finding out? Is there a simpler method than this pseudo code:

  from mutagen import File audio = file ('music.ext') Each audio pic, audio ['covr'] and audio ['apic:'] if no one raises the exception and nobody If not, then we found the album art   

2) I found this album to be embedded in an MP3 file:

How do I download albums in other formats? Can I embed art?

Edit: Embed MP3

  audio = mp3 (filename) data = open (album, rb ') .read () covr = [] if albumart ('MP4Cover.FORMAT_PNG) Code>   

embed flac:

  mutagen.flac import file From, file, FLAC DEP add_flac_cover (filename, album) audio = file (file name) image = image () image.type = 3 if albumart.endswith ('png'): Mime = 'image / png' else: mime = 'Image / jpeg' image.desc = 'front As security cover with the open (Albu-Mart, 'RB') F # better than open (album, RB). Read ()? Image.data = f.read () Audio.Ad_Picture (image). Save ()   

For complete, locate the picture

  def Pict_test (audio): Try: X = Audio Points if X: Except RETURN EXCEPT: Pass in 'covr' or 'apic:' in the audio: return True return False    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -