如何使用python阅读专辑插图? [英] How do I read album artwork using python?

查看:80
本文介绍了如何使用python阅读专辑插图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my searches I have found that there are a few libraries that might be able to do this by reading ID3 tags. If so - which one would be the best to use? I don't plan on writing any data just reading.

我还试图使该应用程序尽可能地可移植,因此最少的依赖项将是一个巨大的好处.

Also I'm trying to make this app as portable as possible so the least amount of dependencies would be a huge bonus.

将感谢您的一些建议.谢谢.

Would appreciate some advice. Thanks.

推荐答案

我建议诱变,这是一个没有其他依赖项的纯python库,它支持许多不同的音频元数据格式/标签(MP3,FLAC,M4A,Monkey's Audio,Musepack等).要从用iTunes保存的ID3 v2.4 MP3中提取插图,请执行以下操作:

I'd recommend mutagen, it's a pure python library with no other dependencies and it supports a lot of different audio metadata formats/tags (MP3, FLAC, M4A, Monkey's Audio, Musepack, and more). To extract artwork from an ID3 v2.4 MP3 saved with iTunes:

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

这篇关于如何使用python阅读专辑插图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆