mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-12 21:22:17 +00:00
Added support for ID3 based metadata, OGG, and FLAC in album art extraction
This commit is contained in:
parent
befc460120
commit
7106d95cee
@ -7,6 +7,7 @@
|
|||||||
#
|
#
|
||||||
# Distributed under terms of the GNU AGPLv3 license.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
|
import base64
|
||||||
import codecs
|
import codecs
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import mutagen
|
import mutagen
|
||||||
@ -140,9 +141,16 @@ def cover_art():
|
|||||||
cover_path = temp_cover.name
|
cover_path = temp_cover.name
|
||||||
for track in res.tracks:
|
for track in res.tracks:
|
||||||
song = mutagen.File(track.path)
|
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)
|
temp_cover.write(song.tags.getall('APIC')[0].data)
|
||||||
break
|
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:
|
else:
|
||||||
raise NotFound('Cover art')
|
raise NotFound('Cover art')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user