适用于Python的eyed3软件包未正确设置ID3元数据 [英] eyed3 package for Python not properly setting ID3 metadata

查看:256
本文介绍了适用于Python的eyed3软件包未正确设置ID3元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为此,我使用的是python 2.7.13,Windows 10和eyed3软件包,如此处所述

For this I am using Python 2.7.13, Windows 10, and the eyed3 package as documented here.

目标:我正在尝试创建一个脚本,该脚本可以为缺少信息的MP3文件输入任何所需的ID3元数据.

Goal: I am trying to create a script that can input any desired ID3 metadata for MP3 files that are missing information.

问题::该脚本似乎可以正确更新元数据,但无法将信息添加到MP3属性的详细信息"屏幕().但是,如果我在运行脚本之前先在这些字段中手动输入数据,则它既可以正确添加元数据,又可以在详细信息"屏幕上显示它!我注意到的另一件事是,我只需要在至少一个字段中输入数据,脚本便可以正确地填充所有字段.这样做似乎可以初始化并允许以某种方式访问​​字段...

Problem: The script appears to update the metadata correctly but fails to add the information to the "Details" screen of the MP3 properties (MP3 Details screen). However, if I first manually input data in those fields before running the script, it correctly both adds the metadata and shows it on the Details screen! Another thing I've noticed is that I only need to enter data in at least one field for the script to then populate all of the fields correctly. Doing this seems to initialize and allow access to the fields in some way...

eyed3文档列出了示例代码,我在这里的代码中或多或少地遵循了这些示例代码:

The eyed3 documentation lists sample code which I have more or less followed exactly in my code here:

import eyed3
import eyed3.mp3

path = [path to some MP3 file]

if eyed3.mp3.isMp3File(path):
     audiofile = eyed3.load(path)   # load file from file path
     audiofile.tag.artist = u"Artist"    # u needed to denote unicode
     audiofile.tag.album_artist = u"Album Artist"
     audiofile.tag.album = u"Album"
     audiofile.tag.save()    # save altered tags

问题:

  1. 在我不知道的MP3属性的详细信息"屏幕上看到的ID3元数据和实际字段之间是否存在隐藏的分隔?
  2. 我看到了另一个关于
  1. Is there some hidden separation between ID3 metadata and the actual fields seen on the Details screen of the MP3 properties that I am unaware of?
  2. I saw another question regarding an eyed3 issue that was solved by using initTag() when the file doesn't have ID3 tags to begin with. Although I haven't gotten the same error, could my issue be related?
  3. Could I be missing an import statement?
  4. Should I just try a different Python module for manipulating ID3 metadata?

我已经尝试了各种测试,但是无法给出可能指向解决方案的任何不同结果.

I've tried all sorts of tests but can't come up with any different results that might point towards a solution.

预先感谢碰巧花时间阅读本文的任何人!任何帮助表示赞赏:)

Thanks in advance to anyone who happens to take the time to read this! Any help is appreciated:)

推荐答案

我遇到了同样的问题,并最终在此线程上找到了解决方案: https://bitbucket.org/nicfit/eyed3/issues/22/tag-save-method-does-not-apply-changes

I was facing the same problem and finally found the solution on this thread: https://bitbucket.org/nicfit/eyed3/issues/22/tag-save-method-does-not-apply-changes

要点:默认情况下,eyed3.load(pathtofile)加载ID3_V2_4标签,而Explorer和Windows Media Player使用1.x标签.

gist: By default eyed3.load(pathtofile) loads ID3_V2_4 tags, and Explorer and Windows Media Player use 1.x tag.

解决方案: 将您的保存语句替换为以下内容:

Solution: Replace your save statement with the following:

   audiofile.tag.save(version=(1,None,None))
   audiofile.tag.save()

第一条语句将确保资源管理器和WMP使用的标签已更新.第二个将确保使用v2.4标记的应用程序也得到更新(示例VLC).希望这会有所帮助!

The first statement will ensure that the tags used by the explorer and WMP are updated. The second will ensure that the applications using the v2.4 tags also get updated (example VLC). Hope this helps!

将来,如果您还计划添加专辑封面,则还应该添加以下内容:

In the future if you plan to add album-art as well, then you should add the following as well:

    audiofile.tag.save(version=(2,3,0))

不确定为什么,但更新v2.3标签似乎可以完成第一次专辑封面更改.

Not exactly sure why but updating the v2.3 tags seems to do the job for first time album-art changes.

这篇关于适用于Python的eyed3软件包未正确设置ID3元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆