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
Removing frames from ID3v2 tag #11
Comments
I fixed this problem by clearing out the frames and removing the last 128 bytes from the file (the ID3v1 tag info). This was a pretty tough gotcha. I didn't see a method for clearing out the tag data, so maybe that would be a nice addition to this library. |
The problem is that TagLib combines the two tag versions (v1 and v2), if both exist. To get rid of this, specify that only ID3v2 should be saved (all other tags are stripped with this):
That wasn't yet documented (sorry about that), I'll do that and keep this issue open until that is done. |
Ah thanks. That will help me clean up some code. Also thanks for the library -- vey helpful! |
This only saves the ID3v2 tags as expected but it doesn't seem to strip out the ID3v1 tags. I'm using version 0.5.0 from rubygems.org. |
Hm, how did you check if the ID3v1 tag is still there? |
OK, so sorry for the conjecture there. It seems that the ID3v1 tags are removed, but somehow when loading up the id3v2 tag, the artist information is back: require 'taglib'
FILENAME = 'example.mp3'
@file = File.new(FILENAME, 'w')
TagLib::MPEG::File.open(FILENAME) do |file|
tag = file.id3v2_tag
tag.artist = "Britt Daniel"
file.save # Saving both id3v2 and id3v1 I suppose.
end
TagLib::MPEG::File.open(FILENAME) do |file|
tag = file.id3v2_tag
tag.remove_frames('TPE1')
# Saving just the ID3v2, should strip ID3v1
file.save(TagLib::MPEG::File::ID3v2)
end
TagLib::MPEG::File.open(FILENAME) do |file|
tag = file.id3v1_tag
artist = tag.artist
puts "When I get just the id3v1 tag, artist is not there: #{artist}"
tag = file.id3v2_tag
artist = tag.artist
puts "But if I load the id3v2 tag, artist is back: #{artist}"
end |
Ok, turns out this is a non-intuitive behavior of TagLib. I've sent a pull request with a fix: In the meantime, use the following to get the desired behavior:
|
Yes, seems to work great. Thanks for all the help with this. |
Released 0.5.1 which documents strip and save -> closing this. |
I was looking for a way to clear out all of the frames from an ID3 tag before setting them. I thought I would cycle through each frame with
frame_list
and callremove_frame
on the tag for each frame. However, I'm having trouble. Whenever I remove frames it seems like I can't get the change to "stick" and they're back when I open the file again.Here's a script showing the problem I'm having.
Is there a way to accomplish what I'm trying to do here?
The text was updated successfully, but these errors were encountered: