tags:

views:

39

answers:

1

Just as the question asks - does anyone have a good example of using the Mutagen python ID3 library to write mp3 files?

I'm looking in particular to add disc/track number information, but examples editing the title and artist would be helpful as well.

Cheers, /YGA

A: 

Did you check out the examples on the web. Some of these should help you.

[Edit:]

Mutagen tutorial is pretty good, hence did not add more information. dir() provides most of the details.

For setting album cover to mp3 using mutagen

Embedding lyrics using mutagen

An example

from mutagen.mp3 import MP3
from mutagen.easyid3 import EasyID3
import mutagen.id3

filename = 'xxx.mp3'

# Example which shows how to automatically add tags to an MP3 using EasyID3

mp3file = MP3(filename, ID3=EasyID3)

try:
    mp3file.add_tags(ID3=EasyID3)
except mutagen.id3.error:
    print("has tags")

mp3file['title'] = 'Newly tagged'
mp3file.save()
print(mp3file.pprint())
pyfunc
... but that example only has reading.
YGA