mirror of
https://github.com/beetbox/beets.git
synced 2025-12-14 12:35:19 +01:00
MPEG-4 album art
This commit is contained in:
parent
7ce2be9103
commit
d6a89fa9bf
1 changed files with 26 additions and 0 deletions
|
|
@ -492,6 +492,21 @@ class ImageField(object):
|
|||
# Unsupported image type.
|
||||
return None
|
||||
|
||||
elif obj.type == 'mp4':
|
||||
if 'covr' in obj.mgfile:
|
||||
covers = obj.mgfile['covr']
|
||||
if covers:
|
||||
cover = covers[0]
|
||||
if cover.format == cover.FORMAT_JPEG:
|
||||
kind = imagekind.JPEG
|
||||
else:
|
||||
kind = imagekind.PNG
|
||||
# cover is an MP4Cover, which is a subclass of str.
|
||||
return (cover, kind)
|
||||
|
||||
# No cover found.
|
||||
return None
|
||||
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
@ -521,6 +536,17 @@ class ImageField(object):
|
|||
)
|
||||
obj.mgfile['APIC'] = picframe
|
||||
|
||||
elif obj.type == 'mp4':
|
||||
if val is None and 'covr' in obj.mgfile:
|
||||
del obj.mgfile['covr']
|
||||
else:
|
||||
if kind == imagekind.JPEG:
|
||||
fmt = mutagen.mp4.MP4Cover.FORMAT_JPEG
|
||||
else:
|
||||
fmt = mutagen.mp4.MP4Cover.FORMAT_PNG
|
||||
cover = mutagen.mp4.MP4Cover(data, fmt)
|
||||
obj.mgfile['covr'] = [cover]
|
||||
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue