1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
TagPy
=====
TagPy is a Python crust (or a set of Python bindings) for Scott Wheeler's
TagLib [1]. It builds upon Boost.Python [2], a wrapper generation library which
is part of the Boost set of C++ libraries [3]. It has its own web site [4].
Just like TagLib, TagPy can:
- read and write ID3 tags of version 1 and 2, with many supported frame types
for version 2 (in MPEG Layer 2 and MPEG Layer 3, FLAC and MPC),
- access Xiph Comments in Ogg Vorbis Files and Ogg Flac Files,
- access APE tags in Musepack and MP3 files.
All these have their own specific interfaces, but TagLib's generic tag
reading and writing mechanism is also supported.
You can find examples in the test/ directory.
Andreas Kloeckner <inform@tiker.net>
[1] http://developer.kde.org/~wheeler/taglib.html
[2] http://www.boost.org/libs/python/doc/
[3] http://www.boost.org
[4] http://mathema.tician.de/software/tagpy
Acknowledgements
================
- Andreas Hemel <debian-bugs@daishan.de> sent a patch for a crash bug.
- Michal Čihař <nijel@debian.org> maintains the Debian package.
- Keith Packard wrote a UCS4 to UTF8 routine that I shamelessly stole.
- Christoph Burgmer wrote the initial version of the new Python-only
FileRef.
Here's his copyright:
* Copyright © 2000 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
Building TagPy
==============
Step 0: Verifying that you have the right dependencies
-------
TagPy works for me with
- TagLib 1.4
- Boost.Python 1.33
- gcc 4.0
I have reason to believe that slightly older versions of gcc and
Boost.Python should be fine, but the 1.4 requirement for TagLib is
firm.
Step 1: Installing Boost.Python
-------
In Debian, it suffices to do "aptitude install libboost-python-dev".
The distribution is preconfigured for this case. You may skip to step
2.
For other distributions, you need to follow the steps at [5]. Roughly,
you must follow the following things:
- Download a Boost release.
- Download and install Boost.Jam, a build tool.
- Build Boost, such as by typing
bjam -sPYTHON_ROOT=/usr -sPYTHON_VERSION=2.4 -sBUILD="release <runtime-link>dynamic <threading>multi"
(You may have to adapt PYTHON_ROOT and PYTHON_VERSION depending on
your system.)
- Check the directory
boost/bin/boost/libs/python/build/libboost_python.so/gcc/release/shared-linkable-true/threading-multi
and find libboost_python*.so. Copy these files to somewhere on your
dynamic linker path, for example:
- /usr/lib
- a directory on LD_LIBRARY_PATH
- or something mentioned in /etc/ld.so.conf
- /usr/local/lib (check that it is in /etc/ld.so.conf!)
You should also create a symbolic link called "libboost_python.so"
to the main .so file.
- Run "ldconfig".
Step 2: Installing TagLib
-------
In Debian, it suffices to do "aptitude install libtag1-dev". The distribution
is preconfigured for this case. You may skip to step 3.
Install TagLib from [1], using the usual
configure; make; make install
For details, you may consult the file `INSTALL' in the TagLib distribution.
Step 3: Installing TagPy
-------
If necessary, edit the file `setup.py', namely the section labelled
"USER CUSTOMIZABLE SECTION" to make sure the compiler will find your
installations of Boost and TagLib.
Then, run
python setup.py build
After a little wait, TagPy should finish building (if not, try and
go back to tweaking `setup.py', depending on the error message).
Finally, typing
su -c "python setup.py install"
will complete the installation.
Congratulations! You are now ready to use TagPy.
Using TagPy
===========
Using TagPy is as simple as this:
>>> import tagpy
>>> f = tagpy.FileRef("la.mp3")
>>> f.tag().artist
u'Andreas'
The test/ directory contains a few more examples.
In general, TagPy duplicates the TagLib API, with a few notable
exceptions:
- Namespaces (i.e. Python modules) are spelled in lower case.
For example, "TagLib::Ogg::Vorbis" is now "taglib.ogg.vorbis".
- Enumerations form their own scope and are not part of any
enclosing class scope, if any.
For example, the value "TagLib::String::UTF16BE" from the
enum "TagLib::String::Type" is now "tagpy.StringType.UTF16BE".
- TagLib::String objects are mapped to and expected as Python
unicode objects.
- TagLib::ByteVector objects are mapped to regular Python
string objects.
|