Python3 eyed3模块,从MP3文件中读取注释?

问题描述 投票:0回答:1

我的目标是使用python3(首选3.8)来读取并最终设置MP3文件的注释标签。

我已经安装了 eyed3 (python3.8 -m pip install eyed3),下面的代码可以加载并读取所有的标签,除了注释。我试着阅读了创建者网站上的文档 (http:/eyed3.nicfit.net)和GitHub网站,但没有任何收获,我也不完全理解下面代码的输出。

import eyed3

music = "/path/to/valid/music/file.mp3"
audio = eyed3.Load(music)

print(audio.tag.comments)

这段代码吐出了以下内容:

<eyed3.id3.tag.CommentsAccessor object at 0x7f54ca55d2b0>

我试着做了一个dir(audio.tag.comments),但除了一堆类位和下面的函数 "get"、"remove"、"set "之外,什么都没有提供。

使用类似:

moo = audio.tag.comments.get()

抛出一个错误。

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mrhobbits/.local/lib/python3.8/site-packages/eyed3/utils/__init__.py", line 138, in wrapped_fn
    return fn(*args, **kwargs)
TypeError: get() missing 1 required positional argument: 'description'

但我找不到任何东西可以告诉我什么是 "描述", 或者我必须深入研究才能得到评论信息?

我还应该提到,使用

print(audio.tag.artist)

也能正常工作并返回

Alestorm

我有点不明白 任何帮助都将是巨大的。

python-3.x audio mp3 eyed3
1个回答
0
投票

算了,不说了。

在这里搜索了一下,发现 "评论 "是一个列表类的对象,而做。

audio.tag.comments[0].text

就能找到我想要的信息

© www.soinside.com 2019 - 2024. All rights reserved.