mirror of
https://github.com/beetbox/beets.git
synced 2026-01-05 07:23:33 +01:00
mediafile: Handle FLAC albumart correctly.
FLAC's metadata_block_picture should just contain the image, not base64'ed like ogg/vorbis wants it. --- beets/mediafile.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
This commit is contained in:
parent
2d4b91fa6d
commit
faa21390a5
1 changed files with 22 additions and 1 deletions
|
|
@ -572,9 +572,23 @@ class ImageField(object):
|
|||
|
||||
# No cover found.
|
||||
return None
|
||||
elif obj.type == 'flac':
|
||||
if 'metadata_block_picture' not in obj.mgfile:
|
||||
return None
|
||||
|
||||
for data in obj.mgfile['metadata_block_picture']:
|
||||
try:
|
||||
pic = mutagen.flac.Picture(data)
|
||||
break
|
||||
except TypeError:
|
||||
pass
|
||||
else:
|
||||
return None
|
||||
|
||||
return pic.data
|
||||
|
||||
else:
|
||||
# Here we're assuming everything but MP3 and MPEG-4 uses
|
||||
# Here we're assuming everything but MP3, FLAC and MPEG-4 use
|
||||
# the Xiph/Vorbis Comments standard. This may not be valid.
|
||||
# http://wiki.xiph.org/VorbisComment#Cover_art
|
||||
|
||||
|
|
@ -624,6 +638,13 @@ class ImageField(object):
|
|||
cover = mutagen.mp4.MP4Cover(val, self._mp4kind(val))
|
||||
obj.mgfile['covr'] = [cover]
|
||||
|
||||
elif obj.type == 'flac':
|
||||
if val is None:
|
||||
pic = mutagen.flac.Picture()
|
||||
pic.data = val
|
||||
pic.mime = self._mime(val)
|
||||
obj.mgfile['metadata_block_picture'] = [pic.write()]
|
||||
|
||||
else:
|
||||
# Again, assuming Vorbis Comments standard.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue