mirror of
https://github.com/beetbox/beets.git
synced 2026-01-03 14:32:55 +01:00
use imghdr directly instead of MIME lib (which uses imghdr)
This commit is contained in:
parent
c20ce11a8c
commit
866c662014
1 changed files with 5 additions and 6 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue