Python (2.6+/3.1+) bindings for the TagLib audio metadata library
Project description
Overview
Requirements
Ubuntu from 12.10
Debian jessie (currently testing) or wheezy-packports
Linux Mint from 14
Arch Linux
Gentoo Linux
Fedora from 17
Installation
The easiest way is to use pip or easy_install:
sudo pip install pytaglib
or
sudo easy_install pytaglib
On systems which use Python 2 by default, this will compile and install the Python 2 version.Use something likesudo pip3 pytaglib
to build the package for Python 3 (the exact command depends on your distribution). Bothcommands can be run with the --user option (and without sudo) which will install everythinginto your home directory.Alternatively, you can download the source tarball and compile manually:
python3 setup.py build python3 setup.py test # optional sudo python3 setup.py install
Replace python3 by the interpreter executable of the desired Python version.
python setup.py build_ext --include-dirs /usr/local/include --library-dirs /usr/local/lib
Usage
The use of the library is pretty straightforward:
Load the library: import taglib
Open a file: f = taglib.File("/path/to/file.mp3")
Read tags from the dict f.tags which maps uppercase tag names to lists of tag values (note that even single values are stored as list in order to be consistent).
Some other information about the file is available as well: f.length, f.sampleRate, f.channels, f.bitrate, and f.readOnly.
Alter the tags by manipulating the dictionary f.tags. You should always use uppercase tag names and lists of strings for the values.
Store your changes: retval = f.save().
If some tags could not be saved because they are not supported by the underlying format, those will be contained in the list returned from f.save().
$ python Python 3.3.0 (default, Sep 29 2012, 15:50:43) [GCC 4.7.1 20120721 (prerelease)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import taglib >>> f = taglib.File("x.flac") >>> f File('x.flac') >>> f.tags {'ARTIST': ['piman', 'jzig'], 'ALBUM': ['Quod Libet Test Data'], 'TITLE': ['Silence'], 'GENRE': ['Silence'], 'TRACKNUMBER': ['02/10'], 'DATE': ['2004']} >>> f.tags["ALBUM"] = ["Always use lists even for single values"] >>> del f.tags["GENRE"] >>> f.tags["ARTIST"].remove("jzig") >>> retval = f.save() >>> retval {} >>>
Contact
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.