Welcome to mpd_pydb’s documentation!

Contents:

Installation

PyPI

Lala is available on the Python Package Index. This makes installing it with pip as easy as:

pip install mpd_pydb

Git

If you want the latest code or even feel like contributing, the code is available on Github.

You can easily clone the code with git:

git clone git://github.com/mineo/mpd_pydb.git

Now you can start hacking on the code or install it system-wide:

python setup.py install

Usage

To use this module, simply import import it:

import mpd_pydb

and read your MPD database into an Database object:

db = mpd_pydb.Database.read_file("/path/to/the/database.db")

Song objects

A song object is a namedtuple() object with each tag type defined in the MPD database available as a field. In addition to the tag types you can configure in MPDs configuration file, 3 additional fields are available:

Time
The length of the song as a float.
mtime
The time at which the file was last modified, in Unix time as an int.
path
The path to the file inside of MPDs music directory as an Path object
music_dir_
The absolute path to the music directory on the local hard drive. This is used to implement support for PEP 519’s os.PathLike.__fspath__() method on the song objects.

API:

MPD PyDB

class mpd_pydb.db.Database(format_version, mpd_version, supported_tags, songs=None)[source]

Bases: object

Parameters:
  • format_version (int) –
  • mpd_version (str) –
  • supported_tags (iterable) –
  • songs ([namedtuple]) – A list of songs in the database
Raises:
  • ValueError – If the format_version is not supported or mpd_version is None
  • TypeError – If supported_tags is not iterable
add_song(song)[source]

Add song to this DB.

Parameters:song (namedtuple) –
format_version = None

The database format version

mpd_version = None

The version of MPD that created this database

classmethod read_file(filename, music_dir=None)[source]

Read the database in filename.

Parameters:
  • filename (str) – The path to the database file
  • music_dir (str) – The path to MPDs music directory
songs = None

A list of songs in this database

supported_tags = None

A list containing the names of all supported tags

to_dataframe()[source]

Convert this database to a pandas DataFrame. In addition to the tags already loaded, the two columns TotalDiscs and TotalTracks will be populated with the values from Disc and Track tags (ID3 only). The Disc and Track tags will no longer contain information about the total amount of discs and tracks after the conversion.

Return type:DataFrame

Indices and tables