Create new ID3 tag using python and eyed3

时光总嘲笑我的痴心妄想 提交于 2019-12-01 15:56:03

问题


I have a bunch of mp3 files that have no ID3 tag at all. I am trying to use eyed3 to add an ID3 tag to the files, but cannot figure out what method to use. Here is my code:

import eyed3

file = eyed3.load("test.mp3")
file.tag.artist = u"MP3 Artist"

I get the following error: "AttributeError: 'NoneType' object has no attribute 'artist'"

I have figured out that it is because the MP3 file doesn't have any ID3 tag at all. If I do this using other MP3 files that already have tags, it works fine. How do I attach a new ID3 tag to the MP3?


回答1:


You need to run initTag first to initialize the tag:

import eyed3

file = eyed3.load("test.mp3")
file.initTag()
file.tag.artist = u"MP3 Artist"


来源:https://stackoverflow.com/questions/31326789/create-new-id3-tag-using-python-and-eyed3

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