You are not logged in.
I'm working on a project right now that is going to read the id3v2 comment tag from an MP3 file, parse some things from it, and then append some text to the end.
Right now I'm using id3v2 from extra to do this:
comm = commands.getoutput( "id3info '%s' | grep '(Comments): ()'" % fileName )
Then I use this to put it back:
os.system( "id3tag -c \"%s\" '%s'" % (commNew, fileName) )
I really don't want to rely on this package to insert this comment. I've been looking at eyeD3 and mutagen for a better way to do this, but I'm having trouble figuring it out.
I know there has to be a more elegant solution out there. Any ideas?
Last edited by ltpl4y3r (2009-04-05 05:00:52)
Offline
you can use mutagen, a tagging lib written in python.
Offline
Thanks Zariel, I had looked at mutagen before, but had never been able to edit the COMM tag properly. After toying with it and dissecting mid3v2. I was able to come up with the following:
import mutagen.id3
filename = 'File.mp3'
id3 = mutagen.id3.ID3(filename)
frame = mutagen.id3.COMM(encoding=3, lang='XXX', desc=u'', text=[u'Great comment!'])
id3.add(frame)
id3.save()
Adding [Solved] tag...
Offline
I think you can use EasyID3 and just do
from mutagen.id3 import EasyID3
file = EasyID3("file")
file["comment"] = comment
file.save()
(not sure if its actually that though)
Offline