eyed3 package for Python not properly setting ID3 metadata

烂漫一生 提交于 2019-12-09 21:31:23

问题


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

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

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...

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

Questions:

  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:)


回答1:


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

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()

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!

EDIT: 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))

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



来源:https://stackoverflow.com/questions/41495351/eyed3-package-for-python-not-properly-setting-id3-metadata

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!