Python (2.6+/3.1+) bindings for the TagLib audio metadata library
Project description
Overview
Requirements
Installation
Linux / Unix
-
sudo pip install pytaglib
Be careful to call pip for the correct Python version; you might needsomething likesudo pip3 pytaglib
to build the package for Python 3 (the exact command depends on your distribution). The commandcan also 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:
python setup.py build python setup.py test # optional sudo python setup.py install
Again, replace python by the interpreter executable of the desired Python version.
python setup.py build_ext --include-dirs /usr/local/include --library-dirs /usr/local/lib
Windows
Install binary distribution
When you are using a 64-bit Python 3.5 on Windows, a simple pip install pytaglib should pull and install the library.
Manual installation
Install Microsoft Visual Studio 2015 Community Edition. In the installation process, be sure to enable C/C++ support.
Download and build taglib:
Download the current taglib release and extract it somewhere on your computer.
Start the VS2015 x64 Native Tools Command Prompt. On Windows 8/10, it might not appear in your start menu, but you can find it here: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts
Navigate to the extracted taglib folder and type: cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=".\install to generate the Visual Studio project files.
Type msbuild INSTALL.vcxproj /p:Configuration=Release which will “install” taglib into the install subdirectory.
Still in the VS2015 command prompt, navigat to the pytaglib directory.
Tell pytaglib where to find taglib: set TAGLIB_HOME="C:\Path\To\Taglib\install"
Build pytaglib: python setup.py build and install: python setup.py install
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.
Source Distribution
Built Distribution
Hashes for pytaglib-1.2.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc844a8bf9626f85e337eeded361a23f40621bf67b9a2bf3aae8bed616de0a9a |
|
MD5 | 31548dff5858b826cc0c179953c0c555 |
|
BLAKE2b-256 | 10dbbf4fa718b7c05f02e7ea2cbbd2f55420bc0525ce2ecfa48b0bfa773cc338 |