cross-platform, Python 2.x/3.x audio metadata ("tagging") library based on TagLib
Project description
pytaglib
pytaglib is a Python audio tagging library. It is cross-platform, works with all Python versions, 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,
- support multiple values per tag.
pytaglib is a very thin wrapper (<150 lines of code) around the fast and rock-solid TagLib C++ library.
News
See the Changelog.
Get it
In most cases, you should install pytaglib with pip:
pip install pytaglib
See installation notes below for requirements and manual compilation.
Usage
>>> import taglib
>>> song = taglib.File("/path/to/my/file.mp3")
>>> song.tags
{'ARTIST': ['piman', 'jzig'], 'ALBUM': ['Quod Libet Test Data'], 'TITLE': ['Silence'], 'GENRE': ['Silence'], 'TRACKNUMBER': ['02/10'], 'DATE': ['2004']}
>>> song.length
239
>>> song.tags["ALBUM"] = ["White Album"] # always use lists, even for single values
>>> del song.tags["DATE"]
>>> song.tags["GENRE"] = ["Vocal", "Classical"]
>>> song.tags["PERFORMER:HARPSICHORD"] = ["Ton Koopman"]
>>> song.save()
For detailed API documentation, use the docstrings of the taglib.File class or view the source code directly.
Note: pytaglib uses unicode strings (type str in Python 3 and unicode in Python 2) for both tag names and values. The library converts byte-strings to unicode strings on assignment, but it is recommended to provide unicode strings only to avoid encoding problems.
pyprinttags
This package also installs the pyprinttags script. It takes one or more files as
command-line parameters and will display all known metadata of that files on the terminal.
If unsupported tags (a.k.a. non-textual information) are found, they can optionally be removed
from the file.
Installation Notes
- Ensure that
pipis installed and points to the correct Python version- on Windows, be sure to check install pip in the Python installer
- on Debian/Ubuntu/Mint, install
python3-pip(and/orpython-pip) - you might need to type, e.g.,
pip-3to install pytaglib for Python 3 if your system's default is Python 2.7.
- For Windows users, there are some precompiled binary packages (wheels). See the PyPI page for a list of supported Python versions.
- If no binary packages exists, you need to have both Python and taglib installed with development headers (packages
python3-dev(orpython-dev) andlibtag1-devfor debian / ubuntu and derivates,python-develandtaglib-develfor fedora and friends,brew install taglibon OS X).
Linux: Distribution-Specific Packages
- Debian- and Ubuntu-based linux flavors have binary packages for the Python 3 version, called
python3-taglib. Unfortunatelly, they are heavily outdated, so you should instally the recent version viapipwhenever possible. - For Arch users, there is a package in the user repository (AUR).
Manual Compilation: General
You can download or checkout the sources and compile manually:
python setup.py build
python setup.py test # optional, run unit tests
sudo python setup.py install
Note: The taglib Python extension is built from taglib.cpp which in turn is
auto-generated by Cython from taglib.pyx. To regenerate the taglib.cpp after making changes to taglib.pyx, use setup.py --cython build.
Manual Compilation: Windows
The following procedure was tested for Python 3.5 and Python 3.6 on Windows 10. Other platforms might require different steps; see e.g. this page.
- Install Microsoft Visual Studio 2015 Community Edition. In the installation process, be sure to enable C/C++ support. Alternatively, install Visual Studio 2017, but install the "v140" C++ toolset and use the "Visual Studio 2015" version of the developer command prompt below.
- 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=".\taglib-install"to generate the Visual Studio project files. - Type
msbuild INSTALL.vcxproj /p:Configuration=Releasewhich will "install" taglib into thetaglib-installsubdirectory.
- Still in the VS2015 command prompt, navigate to the pytaglib directory.
- Tell pytaglib where to find taglib:
set TAGLIB_HOME=C:\Path\To\taglib-install - Build pytaglib:
python setup.py buildand install:python setup.py install
Contact
For bug reports or feature requests, please use the issue tracker on GitHub. For anything else, contact me by email.
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
File details
Details for the file pytaglib-1.4.4.tar.gz.
File metadata
- Download URL: pytaglib-1.4.4.tar.gz
- Upload date:
- Size: 111.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3458e64cea61a7d4189f26c601e7bfd82053f3c02c2247cb8c430847927ef18
|
|
| MD5 |
932bc5dbedcda6fd4350ed2949d20c4e
|
|
| BLAKE2b-256 |
66acaea033ff78cd6addca7921afd52ecad62cf4c8a6a7217209dc077229b83f
|