Python: How can I access an mp3 file's metadata using Python? [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-30 12:37:07

问题


Supposing I wanted to see the Artist Name? Or add BPM information? What Python tools could I go about doing this?


回答1:


There's a module called Python-ID3 that does exactly this. If you're on a Debian/Ubuntu box, its package name is python-id3 and there is example code on its website:

from ID3 import *
try:
    id3info = ID3('/some/file/moxy.mp3')
    print id3info
    id3info['TITLE'] = "Green Eggs and Ham"
    id3info['ARTIST'] = "Moxy Früvous"
    for k, v in id3info.items():
        print k, ":", v
except InvalidTagError, message:
    print "Invalid ID3 tag:", message


来源:https://stackoverflow.com/questions/15164646/python-how-can-i-access-an-mp3-files-metadata-using-python

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