Metadata-Version: 2.0
Name: pytaglib
Version: 1.2.1
Summary: Python (2.6+/3.1+) bindings for the TagLib audio metadata library
Home-page: http://github.com/supermihi/pytaglib
Author: Michael Helmling
Author-email: michaelhelmling@posteo.de
License: GPLv3+
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules

``pytaglib`` – TagLib bindings for Python
=========================================

Overview
--------

| ``pytaglib`` is a cross-platform package of
  `Python <http://www.python.org>`__ (2.6+/3.1+) bindings for
| `Taglib <http://taglib.github.io>`__. It provides a full-featured
  audio metadata ("tag") library supporting
| all current versions of Python.

| The package gives you complete freedom over the tag names – you are
  not limited to common tags like
| ``ARTIST``, ``ALBUM`` etc.; instead you may use any string as key as
  long as the underlying metadata
| format supports it (most of them do, including *mp3*, *ogg*, and
  *FLAC*). Moreover, you can even
| use multiple values of the same tag, in order to e.g. store two
  artists, several genres, and so on.

Requirements
------------

| ``pytaglib`` uses Taglib features that have been added in version
  1.8-BETA, so you need at least that
| version along with development headers to compile ``pytaglib``. The
  recent releases of all linux
| flavours nowadays ship taglib ≥ 1.8.

| The use of taglib ≥ 1.9 is recommended, since that release fixes some
  bugs that may affect
| ``pytaglib`` in less common circumstances.

Installation
------------

The most recommended installation method is

::

        pip install pytaglib

where you should ensure that:

-  ``pip`` points to the correct Python version; you might need to use,
   e.g., ``pip-3.5`` to install ``pytaglib`` for another Python version
   than your system's default.
-  you may need administrator rights to install a package, i.e.,
   ``sudo pip install pytaglib`` on Unix or running the command on a
   Admin console on windows
-  you can alternatively install into your user home with
   ``pip install --user pytaglib``.

If the above does not work, continue reading for alternative methods of
installation.

Linux / Unix
~~~~~~~~~~~~

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 use the above "pip" method whenever
   possible.
-  For Arch users, there is a
   `package <https://aur.archlinux.org/packages/python-pytaglib/>`__ in
   the user repository (AUR).

   .. rubric:: Manual Compilation
      :name: manual-compilation

   Alternatively, you can download / checkout the sources and compile
   manually:

   ::

       python setup.py build
       python setup.py test  # optional
       sudo python setup.py install

For this to work, you need to have ``taglib`` installed with development
headers (package ``libtag1-dev`` for deb-based linux). If taglib is
installed on a non-standard location, you can manually specify include
and library directories:

::

    python setup.py build --include-dirs /usr/local/include --library-dirs /usr/local/lib

| **Note**: The ``taglib`` Python extension is built from the file
  ``taglib.cpp`` which in turn is
| auto-generated by `Cython <http://www.cython.org>`__ from
  ``taglib.pyx``. To re-cythonize this file
| instead of using the shipped ``taglib.cpp``, invoke ``setup.py`` with
  the ``--cython`` option.

Windows
~~~~~~~

Currently, the PyPI archive contains a binary version only for
Python3.5/x64. For different combinations of Python version and
architecture, you need to build yourself.

**Note**: The following procedure was tested for Python 3.5 on x64 only.
Other python versions probably require some more work; see e.g.
`this <https://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/>`__
page.

#. Install `Microsoft Visual Studio 2015 Community
   Edition <https://www.visualstudio.com/downloads/download-visual-studio-vs>`__.
   In the installation process, be sure to enable C/C++ support.
#. Download and build taglib:

   #. Download the current `taglib
      release <https://github.com/taglib/taglib/releases>`__ 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()``.

| The following snippet should show the most relevant features. For a
  complete
| reference confer the online help via ``help(taglib.File)``.

::

    $ 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
    {}
    >>>

| **Note:** All strings in the tag dictionary are unicode strings (type
  ``str`` in Python 3 and ``unicode`` in Python 2). On the input side,
  however, the library is rather permissive and supports both byte- and
  unicode-strings. Internally, ``pytaglib`` converts
| all strings to ``UTF-8`` before storing them in the files.

``pyprinttags``
---------------

| This package also installs the small script ``pyprinttags``. 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.

``Contact``
-----------

| For bug reports or feature requests, please use the
| `issue tracker <https://github.com/supermihi/pytaglib/issues>`__ on
  GitHub. For anything else, contact
| me by `email <mailto:michaelhelmling@posteo.de>`__.


