Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep only ID3v2.4 tags, remove ID3v1 and ID3v2.3 tags #651

Open
milahu opened this issue Jun 21, 2024 · 0 comments
Open

keep only ID3v2.4 tags, remove ID3v1 and ID3v2.3 tags #651

milahu opened this issue Jun 21, 2024 · 0 comments

Comments

@milahu
Copy link

milahu commented Jun 21, 2024

i have mp3 files with ID3v1 and ID3v2.3 tags

when i use mutagen to modify the tags
i get files with ID3v1 and ID3v2.3 and ID3v2.4 tags

with updated ID3v1 and ID3v2.4 tags
with the original ID3v2.3 tags

i want to keep only ID3v2.4 tags

$ tageditor --no-color get -f 01.mp3.fixed.mp3 2>&1 | grep -e ID3 -e Title
 - ID3v1 tag
    Title             new title
 - ID3v2 tag (version 2.4.0)
    Title             new title
 - ID3v2 tag (version 2.3.0)
    Title             old title
    Warning      09:36:42   parsing file header: There is more than just one ID3v2 header at the beginning of the file.

with file.save(buf, v2_version=3) i get duplicate ID3v2.3 tags

$ tageditor --no-color get -f 01.mp3.fixed.mp3 2>&1 | grep -e ID3 -e Title
 - ID3v1 tag
    Title             new title
 - ID3v2 tag (version 2.3.0)
    Title             new title
 - ID3v2 tag (version 2.3.0)
    Title             old title
    Warning      09:44:08   parsing file header: There is more than just one ID3v2 header at the beginning of the file.
    Warning      09:44:08   parsing TDRC frame: The frame is only supported in ID3v2.4 and newer but the tag's version is ID3v2.3.
import io
import mutagen

name = "01.mp3"

file = mutagen.File(name)

file.tags.add(mutagen.id3.TIT2(
    text=f"new title",
    encoding=mutagen.id3.Encoding.UTF8
))

buf = io.BytesIO()
with open(name, "rb") as f:
    buf.write(f.read()) # todo chunks

name2 = name + ".fixed.mp3"

#file.save(name2) # error: no such file
file.save(buf)

# write ID3v1 and ID3v2.3 tags
# dont write ID3v2.4 tags for better compatibility
#file.save(buf, v2_version=3)

with open(name2, "wb") as f:
    f.write(buf.getvalue())

print("TODO check", name2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant