1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-09 19:52:16 +00:00

Added support for ID3 based metadata, OGG, and FLAC in album art extraction

This commit is contained in:
Taizo Simpson 2018-10-08 16:34:44 -04:00
parent befc460120
commit 7106d95cee
No known key found for this signature in database
GPG Key ID: D197B1197B2D4D68

View File

@ -7,6 +7,7 @@
#
# Distributed under terms of the GNU AGPLv3 license.
import base64
import codecs
import mimetypes
import mutagen
@ -140,9 +141,16 @@ def cover_art():
cover_path = temp_cover.name
for track in res.tracks:
song = mutagen.File(track.path)
if type(song) == mutagen.mp3.MP3 and len(song.tags.getall('APIC')) > 0:
if isinstance(song.tags, mutagen.id3.ID3Tags) and len(song.tags.getall('APIC')) > 0:
temp_cover.write(song.tags.getall('APIC')[0].data)
break
elif isinstance(song, mutagen.flac.FLAC) and len(song.pictures):
temp_cover.write(song.pictures[0].data)
break
elif isinstance(song.tags, mutagen._vorbis.VCommentDict) and 'METADATA_BLOCK_PICTURE' in song.tags and len(song.tags['METADATA_BLOCK_PICTURE']) > 0:
picture = mutagen.flac.Picture(base64.b64decode(song.tags['METADATA_BLOCK_PICTURE'][0]))
temp_cover.write(picture.data)
break
else:
raise NotFound('Cover art')
else: