Welcome to mpd_pydb’s documentation!¶
Contents:
Installation¶
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: Raises: - ValueError – If the format_version is not supported or mpd_version is None
- TypeError – If
supported_tags
is not iterable
-
format_version
= None¶ The database format version
-
mpd_version
= None¶ The version of MPD that created this database
-
songs
= None¶ A
list
of songs in this database
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
andTotalTracks
will be populated with the values fromDisc
andTrack
tags (ID3 only). TheDisc
andTrack
tags will no longer contain information about the total amount of discs and tracks after the conversion.Return type: DataFrame