I use this function:
def set_trackno(f, track):
"""Set id3 track number"""
audio = MP3(f)
audio["TRCK"] = TRCK(encoding=3, text=[unicode(track)])
audio.save()
To try to set an id3 tag on a file that lacks it. It throws no exception. But it simply does'nt work. Why is that? Here is a sample output:
In [1]: %paste
def set_trackno(f, track):
"""Set id3 track number"""
audio = MP3(f)
audio["TRCK"] = TRCK(encoding=3, text=[unicode(track)])
audio.save()
## -- End pasted text --
In [2]: from mutagen.mp3 import MP3
In [3]: from mutagen.id3 import TRCK
In [4]: set_trackno('/home/nine/Musik/Kristet/Buster Inc/Buster_Inc.-Summertime.mp3', 1)
In [5]: exit
nine@nine-laptop:~/Musik/Kristet/Buster Inc$ id3v2 -l Buster_Inc.-Summertime.mp3
Buster_Inc.-Summertime.mp3: No ID3 tag
nine@nine-laptop:~/Musik/Kristet/Buster Inc$
Update 1
I changed the function to this (see last line in code):
def set_trackno(f, track):
"""Set id3 track number"""
audio = MP3(f)
audio["TRCK"] = TRCK(encoding=3, text=unicode(track))
audio.tags.save(v1=2)
And now it writes id3 version 1 (which seems pretty obvious). But I can't figure out how to write a version 2. audio.tags.save()
won't do...