ID3 Tagging in Python (original) (raw)
This module allows one to read and manipulate so-called ID3 informational tags on MP3 files through an object-oriented Python interface. Note that this is the first thing I've ever written in Python, so please bear with me if I've done something atrociously wrong.
This module is hosted on SourceForge.net. Please visit the project page there.
Version History:
- 1.2 (05 April 2002): New dictionary-based interface to ID3 fields. Changed id3-tagger.py and examples to use new interface. Changed default genre to 255 (Unknown), not 0 (Blues).
- 1.1 (08 November 2001): This release was long delayed, mostly because I forgot to do it. Fixes Windows issues by opening files in binary mode, as well as a few other buglets.
- 1.0 (21 September 2000): ID3v1.1 (track number) support based on patches from Jim Speth (speth@end.com) and another party whose email I seem to have lost. (Sorry about that!) First 1.0 release; added README, COPYING, and CHANGES files. Added setup.py file for Distutils and Python 1.6 users. Now automatically chops whitespace and trailing nulls off the ends of ID3 fields.
- 0.6 (11 June 1999): Fix from Arne Zellentin (arne@unix-ag.org) to prevent wiping out the last 128 bytes of MP3 files that don't already have an ID3 tag. Oops!
- 0.5 (2 May 1999): Initial release.
Fetch the source (current version 1.2) or browse the source. You can also browse the CVS repository.
Here is a simple example of using the ID3 module. See the module itself for more documentation. This example sets the title and artist fields on an MP3 file.
from ID3 import *
try:
id3info = ID3('/some/file/moxy.mp3')
print id3info
id3info['TITLE'] = "Green Eggs and Ham"
id3info['ARTIST'] = "Moxy Früvous"
for k, v in id3info.items():
print k, ":", v
except InvalidTagError, message:
print "Invalid ID3 tag:", message
I have written another small example program, id3-tagger.py, which can print out the ID3 tags, formatted nicely, of all the files specified as arguments to the program. It can also set any field on the MP3 file, including the genre field, which can be set either by number or by name. It's included in the main distribution.
Debian GNU/Linux packages of ID3.py are available in the main Debian distribution.
Jeff Abbott has kindly provided some RPMs. (You can also get the source RPMs.)
Last modified: Fri Apr 5 11:53:42 JST 2002