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:
- 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?
- 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?
- Could I be missing an import statement?
- 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:)
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