我正在尝试使用 eyed3 作为 Python 库,以便更改大量 .MP3 文件的艺术家名称。我尝试使用该项目网页的示例代码(http://eyed3.nicfit.net/),并且 setsaudiofile.tag.artist 更改了“特约艺术家”。根据文档(位于http://eyed3.nicfit.net/api/eyed3.html),标签对象没有其他艺术家字段。
是否可以使用 eyed3 来实际更改专辑艺术家?如果是这样,你能提供清晰、简洁的 Python 代码吗?
我正在尝试使用 eyed3 作为 Python 库,以便更改大量 .MP3 文件的艺术家名称。我尝试使用该项目网页的示例代码(http://eyed3.nicfit.net/),并且 setsaudiofile.tag.artist 更改了“特约艺术家”。根据文档(位于http://eyed3.nicfit.net/api/eyed3.html),标签对象没有其他艺术家字段。
是否可以使用 eyed3 来实际更改专辑艺术家?如果是这样,你能提供清晰、简洁的 Python 代码吗?
这是我前段时间写下的用于更改该字段的命令:
eyeD3 --set-text-frame=TPE2:"Various Artists" filename.mp3
其中“Various Artists”是您在“专辑艺术家”字段中想要的值。
对于大量 MP3,您可以将一位艺术家的所有歌曲放在一个特定文件夹中。例如:- 所有“Coldplay”歌曲都在“Coldplay”文件夹中
如果您在 Linux 上,您可以执行以下操作:-
import os
import eyed3
folder = raw_input('Please enter the folder of music')
files = os.listdir(folder) # This will give us a list of all of the MP3s in that folder
artist = folder.split('/')[-1]
for x in files:
mp3 = eyed3.load(folder + '/' + x) # Loads each and every MP3
mp3.tag.artist = unicode(artist, "UTF-8") # Sets the "artist" tag to the artist name
mp3.tag.save() # Saves tag
如果您在 Windows 上,只需通过将所有斜杠“/”变为反斜杠“\”来编辑代码
上面的代码对我来说效果很好。很高兴我能帮忙:)