【问题标题】:Setting an ID3 comment using EyeD3 in Python在 Python 中使用 EyeD3 设置 ID3 注释
【发布时间】:2014-06-28 19:25:57
【问题描述】:

我在一个带有 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)

“流派”已正确设置或更改,但我的评论只是添加了一些垃圾。我在评论中添加了 winamp 中的“测试”,在我运行脚本并从命令行输出 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]
þ
-------------------------------------------------------------------------------

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

【问题讨论】:

    标签: python eyed3


    【解决方案1】:

    我不会假装理解为什么会这样,但请查看 the handy example file 中的 cmets 是如何设置的:

    from eyed3.id3 import Tag
    
    t = Tag()
    t.comments.set(u"Gritty, yo!")
    

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

    这适用于版本:

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

    【讨论】:

    • 对于我的代码,我不得不将其更改为:tag.tag.cmets.set(u"Gritty, yo!")。成功了,谢谢!
    • 您知道您使用的是哪个版本的 eyed3 吗?我刚刚在上面添加了我的。多年来 API 似乎发生了变化......
    猜你喜欢
    • 1970-01-01
    • 2023-03-11
    • 2014-08-05
    • 1970-01-01
    • 2013-01-24
    • 2021-04-16
    • 2012-05-25
    • 2012-06-12
    • 1970-01-01
    相关资源
    最近更新 更多