如何使用python阅读专辑封面?

She*_*don 5 python mp3 id3 object

在我的搜索中,我发现有一些库可以通过读取ID3标签来实现.如果是这样 - 哪一个最好用?我不打算只是阅读任何数据.

此外,我正在努力使这个应用程序尽可能便携,所以最少的依赖将是一个巨大的奖金.

会很感激一些建议.谢谢.

zee*_*kay 18

我推荐mutagen,它是一个没有其他依赖关系的纯python库,它支持许多不同的音频元数据格式/标签(MP3,FLAC,M4A,Monkey's Audio,Musepack等).要从使用iTunes保存的ID3 v2.4 MP3中提取艺术作品:

from mutagen import File

file = File('some.mp3') # mutagen can automatically detect format and type of tags
artwork = file.tags['APIC:'].data # access APIC frame and grab the image
with open('image.jpg', 'wb') as img:
   img.write(artwork) # write artwork to new image
Run Code Online (Sandbox Code Playgroud)