Python: How can I access an mp3 file's metadat

2020-03-30 04:58发布

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

1条回答
做自己的国王
2楼-- · 2020-03-30 05:11

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
查看更多
登录 后发表回答