How do I read album artwork using python? [closed]

∥☆過路亽.° 提交于 2019-12-21 02:31:10

问题


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.


回答1:


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



回答2:


ID3 is a rather simple format. If you only need to extract a very limited subset and you want to limit dependencies, then you should consider taking a look at the reference and extracting just the data you're looking for.



来源:https://stackoverflow.com/questions/6171565/how-do-i-read-album-artwork-using-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!