Closed Scarlet06 closed 7 months ago
Even though I am a tad late to the party, let me through in my two cents. Maybe there are id3v1 tags present? If I understand correctly, the default is to only save id3v2, leaving id3v1 alone unless instructed otherwise. I am fairly new to this package and have so far only used the command line interface. This seems to validate my guess, though:
# The default version for eyeD3 tags and save operations.
ID3_DEFAULT_VERSION = ID3_V2_4
(found in __init__
of id3
)
My main program is actually doing this (I'll show a snippet here below), but it doesn't seem to solve this probelm. I can't really understand why it doesn't work.
import eyed3
song_path = "path/to/file.mp3"
mp3 = eyed3.load(song_path)
if mp3.tag is None:
mp3initTag(eyed3.id3.ID3_V2_4)
elif mp3.tag.version<eyed3.id3.ID3_V2_4:
mp3.tag.version=eyed3.id3.ID3_V2_4
IDJK why it isn't solving my problem
My point is that there might be id3v1 tags in that file. Some taggers optionally include them for compatibility with legacy apps. What I grasp from your very limited snippet is that your main program only acts on idv2, leaving the v1 tags alone. I guess that Windows then picks up those v1 tags where it can't find a value in v2.
Have you tried checking with the eyeD3 command line program?
eyeD3 --verbose -1 "path\to\file"
That should show you all id3v1 tags. You can clear them with --remove-v1
. See what Windows shows after you have done that.
Uuuh, that's clever. Now I understand what you meant. I was able to write a clunky patch to make my program work as I wanted. I'll write my solution below so that if anyone would ever met the same problem, they can peek it.
I tried my best to add some usefull comments (I'm not very good at it)
import eyed3
from eyed3.id3 import ID3_V1, ID3_V2_4
song_path = r"C:\Users\danie\Desktop\Originale.mp3"
# I load the same song with both ID3 versions
# I'll keep song_v2
song_v1 = eyed3.load(song_path, ID3_V1)
song_v2 = eyed3.load(song_path, ID3_V2_4)
if song_v1.tag is not None:
# the song has ID3 v1 tags
if song_v2.tag is None:
# the song doesn't have ID3 v2 tags
# specifying the version will convert the metadata
song_v1.tag.save(version=ID3_V2_4)
song_v2 = song_v1
elif song_v2.tag.version<ID3_V2_4:
# the song has ID3 v2 tags but isn't the latest
song_v2.tag.save(version=ID3_V2_4)
# it removes the extra metadata ID3 v1 I don't want to keep
song_v2.tag.remove(song_path, song_v1.tag.version)
elif song_v2.tag is None:
# the song doean't have ID3 v1 tags, but doesn't have v2's either
# it creates a ID3 v2 tag for the song
song_v2.initTag(ID3_V2_4)
elif song_v2.tag.version<ID3_V2_4:
# the song has ID3 v2 tags but isn't the latest version
song_v2.tag.save(version=ID3_V2_4)
mp3 = song_v2
I'm using it with python 3.11.4 on a windows 11 22H2 version. I have downloaded an mp3 file (version 2.3.0) that already has a track number. If I try to empty this tag, it updates the data, but looking at the properties of the file on windows, it shows the track number is still there. If I set another number instead, windows can show it the same new number, but again setting it to None and looking through windows, shows the initial value instead. Is there something I'm doing wrong?
The code is pretty simple tho, and it worked with other mp3 files:
Or is there a procedure I can apply to make sure also the property that windows can look for is being changed?