使用python和eyed3创建新的ID3标签 [英] Create new ID3 tag using python and eyed3

查看:259
本文介绍了使用python和eyed3创建新的ID3标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆根本没有ID3标签的mp3文件.我正在尝试使用eyed3向文件添加ID3标签,但无法弄清楚使用哪种方法.这是我的代码:

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"

我收到以下错误:"AttributeError:'NoneType'对象没有属性'artist'"

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

我发现这是因为MP3文件根本没有任何ID3标签.如果我使用已经具有标签的其他MP3文件来执行此操作,则效果很好.如何在MP3上附加新的ID3标签?

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?

推荐答案

您需要运行

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"

这篇关于使用python和eyed3创建新的ID3标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆