在Python中使用EyeD3设置ID3注释

时间:2021-04-03 09:22:27

I have the following python script in a folder with a mp3 file:

我在带有mp3文件的文件夹中有以下python脚本:

import os
import eyed3

def track(file):
    tag = eyed3.load(file)
    tag.tag.comment = u"teststring"
    tag.tag.genre = u"Pop"
    tag.tag.save()

for fn in os.listdir('.'):
    print fn[-3:]
    if fn[-3:] == 'mp3':
        track(fn)

The 'genre' is set or changed correctly, but my comment is just adding some garbage. I added a 'Test' in winamp to the comment, and after I run my script and output the ID3 info from the commandline, I see this:

“流派”设置或更改正确,但我的评论只是添加一些垃圾。我在winamp中添加了一个'Test'来评论,在我运行我的脚本并从命令行输出ID3信息后,我看到了:

ys3(01).mp3 [ 3.86 MB ]
-------------------------------------------------------------------------------
Time: 03:02 MPEG1, Layer III    [ ~177 kb/s @ 48000 Hz - Joint stereo ]
-------------------------------------------------------------------------------
ID3 v2.3:
title: WANDERERS FROM YS    - ?
artist: 
album: 
track:      genre: Pop (id 13)
Comment: [Description: ] [Lang: eng]
Test
Comment: [Description: ÿþÿ] [Lang: eng]
þ
-------------------------------------------------------------------------------

Am I passing the 'Comment' in the wrong way?

我是以错误的方式传递“评论”吗?

1 个解决方案

#1


0  

I don't pretend to understand why this is the way it is, but check out how comments are set in the handy example file:

我不假装理解为什么会这样,但请查看如何在方便的示例文件中设置注释:

from eyed3.id3 import Tag

t = Tag()
t.comments.set(u"Gritty, yo!")

I believe this has to do with comments being placed into frames, but others may have to chime in with corrections on that. Note that this will fail unless you pass it unicode.

我认为这与将评论置于框架中有关,但其他人可能不得不对此进行更正。请注意,除非您传递unicode,否则这将失败。

This works on version:

这适用于版本:

↪ eyeD3 --version
eyeD3 0.7.4-beta (C) Copyright 2002-2013 Travis Shirk

#1


0  

I don't pretend to understand why this is the way it is, but check out how comments are set in the handy example file:

我不假装理解为什么会这样,但请查看如何在方便的示例文件中设置注释:

from eyed3.id3 import Tag

t = Tag()
t.comments.set(u"Gritty, yo!")

I believe this has to do with comments being placed into frames, but others may have to chime in with corrections on that. Note that this will fail unless you pass it unicode.

我认为这与将评论置于框架中有关,但其他人可能不得不对此进行更正。请注意,除非您传递unicode,否则这将失败。

This works on version:

这适用于版本:

↪ eyeD3 --version
eyeD3 0.7.4-beta (C) Copyright 2002-2013 Travis Shirk