From 866c662014cdaa4fd161b2d2afdb487b181b3985 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Thu, 21 Apr 2011 00:42:16 -0700 Subject: [PATCH] use imghdr directly instead of MIME lib (which uses imghdr) --- beetsplug/embedart.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py index 4f256fec7..080c6d6e9 100755 --- a/beetsplug/embedart.py +++ b/beetsplug/embedart.py @@ -1,5 +1,5 @@ import logging -from email.mime.image import MIMEImage +import imghdr from beets.plugins import BeetsPlugin from beets import mediafile @@ -14,16 +14,15 @@ class EmbedCoverArtPlugin(BeetsPlugin): def album_imported(lib, album): if album.artpath: data = open(album.artpath, 'rb').read() - img = MIMEImage(data) - mime_img = img.get_content_subtype() + kindstr = imghdr.what(None, data) - if mime_img == 'jpeg': + if kindstr == 'jpeg': kind = mediafile.imagekind.JPEG - elif mime_img == 'png': + elif kindstr == 'png': kind = mediafile.imagekind.PNG else: log.error('A file of type %s is not allowed as coverart.' - % mime_img) + % kindstr) return # Add art to each file.