pytag is a Python audio tagging library. It is cross-platform, and is very simple to use yet fully featured:
- supports more than a dozen file formats including mp3, flac, ogg, wma, and mp4,
- support arbitrary, non-standard tag names,
pytag is a very thin wrapper (≈366 lines of code) around the fast and rock-solid TagLib C++ library.
import pytag
>>> song = pytag.File('/path/to/my/file.mp3')
>>> tag = song.tags
>>> tag.title
Hussein Sarea
>>> tag.title = 'New title'
>>> tag.title
New title
>>> song.save()
>>> song.close()
import pytag
path = Path('/path/to/my/file.mp3')
with pytag.File(path) as tfile:
tags = tfile[0]
properties = tfile[1]
# delete a specific tag
del tags.title
# edit a tag
tags.artist = 'new artist'
# you can also get audio properties information
print(properties.length)
print(properties.minutes)
print(properties.seconds)
print(properties.bitrate)
print(properties.samplerate)
print(properties.channels)
You can download or checkout the sources and compile manually:
python setup.py build
python setup.py test # optional, run unit tests
python setup.py install