python - 删除音乐文件元数据标签

标签 python python-2.7 metadata flac mutagen

如何从 FLAC 文件或 MP3 ID3 标签中删除元数据标签?我可以使用mutagen编辑信息,但如何删除部分信息?

我需要删除名为 fmps_playcount 的标签,但不需要删除其余元数据。

最佳答案

对于 ID3 标签,您可以使用 delall 删除框架。例如:

>>> print audio.pprint()
TPE1=Agalloch
TALB=The Mantle
TRCK=1/9
TIT2=A Celebration For The Death Of Man...
TCON=Metal
>>> audio.delall('TCON')
>>> print audio.pprint()
TPE1=Agalloch
TALB=The Mantle
TRCK=1/9
TIT2=A Celebration For The Death Of Man...

对于删除 FLAC 元数据(我没有任何 FLAC 文件来测试这一点),我有一个很好的感觉:

>>> del audio['tag_to_delete']

由于帮助文档中有:

 |  __delitem__(self, key)
 |      Delete a metadata tag key.
 |      
 |      If the file has no tags at all, a KeyError is raised.

您可以在此处阅读有关 delitem 魔术方法的更多信息: http://www.rafekettler.com/magicmethods.html

关于python - 删除音乐文件元数据标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17538328/

相关文章:

python - 调用方法的最佳方式 - Python

oracle - SQLAlchemy MetaData.reflect 在 Oracle 数据库中找不到表

python 子类

python-2.7 - 使用 numpy 计算文本文档之间的 Kullback-Leibler (KL) 距离

python - 将 python 模块添加到 Azure

video - 如何使用 FFMPEG 为字幕流设置自定义 handler_name 元数据

swift - 在 Swift 2 Xcode 7 中从 .pls 接收元数据

python - Spyder 中的缩进指示

python - 从列表中的每个值中减去动态值

Python 错误 "NameError: global name ' self' is not defined"在同一个类中调用另一个方法时