如何提取“编码人"?从mp3元数据使用Python? [英] How to extract "Encoded by" from mp3 metadata using Python?
问题描述
我正在尝试编写Python脚本以从某些mp3文件中提取元数据标签.具体来说,我想提取专辑"和编码人",如果我右键单击文件并查看详细信息,这些文件将可用:
I am trying to write a Python script to extract metadata tags from some mp3 files. Specifically, I am looking to extract "Album" and "Encoded by", which are available if I right-click on the files and look under details:
我目前正在使用 eyeD3 库来解析元数据.我之所以使用这个库,是因为我认为它可以轻松完成我的任务,但我并不嫁给它.
I am using currently using the eyeD3 library to parse metadata. I am using this library because I thought it would easily accomplish my task, but I am not married to it.
我能够很容易地提取专辑",但不能提取编码人"字段.如果我打印了所有歌曲标签,则看不到所需的编码人"字段.有什么想法吗?
I am able to extract the "Album" easily enough, but not the "Encoded by" field. If I print out all the song tags, I do not see anything like the "Encoded by" field I need. Any ideas, please?
这是我的代码:
import eyed3
def main():
music_file = r'G:\Music Collection\54-40\Sweeter Things A Compilation\01 Miss You - 54-40.mp3'
audiofile = eyed3.load(music_file)
for attribute_name in dir(audiofile.tag):
attribute_value = getattr(audiofile.tag, attribute_name)
print attribute_name, attribute_value
if __name__ == "__main__":
main()
print 'done'
推荐答案
事实证明,编码为"字段埋在frame_set
对象返回的列表中:audiofile.tag.frame_set['TENC'][0].text
It turns out the "Encoded by" field is buried in a list returned by the frame_set
object: audiofile.tag.frame_set['TENC'][0].text
这篇关于如何提取“编码人"?从mp3元数据使用Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!