参考以下代码,一看就懂:
# need python3
from mutagen.easyid3 import EasyID3
import os
basedir = os.path.abspath(os.path.dirname(__file__))
# print(basedir)
def process(file_dir):
L=[]
for root, dirs, files in os.walk(file_dir):
for file in files:
# print(file)
if file.find(".mp3") > 0:
print(file)
arr = file.rsplit('.',1)
audio = EasyID3(basedir+"/"+file)
audio['artist'] = u"Me"
audio.save()
process(basedir)
# 其他用法
# audio = EasyID3("example.mp3")
# audio['title'] = u"Example Title"
# audio['artist'] = u"Me"
# audio['album'] = u"My album"
# audio['composer'] = u"" # clear
# audio.save()
# import eyed3
# audiofile = eyed3.load("song.mp3")
# audiofile.tag.artist = u"Nobunny"
# audiofile.tag.album = u"Love Visions"
# audiofile.tag.title = u"I Am a Girlfriend"
# audiofile.tag.track_num = 4
# audiofile.tag.save()