# Music Player Daemon client module

An MPD (Music Player Daemon) client library written in pure Python.

Documentation:

  https://kaliko.gitlab.io/python-musicpd

MPD Protocol:

  https://www.musicpd.org/doc/html/protocol.html

Code:

  https://gitlab.com/kaliko/python-musicpd

Dependencies:

  None

Compatibility:

  Python 3.6+

Licence:

  GNU LGPLv3

## Installation

Latest stable release from PyPi:

    pip install python-musicpd

Latest development version using pip + git:

    pip install git+https://gitlab.com/kaliko/python-musicpd.git@dev

## Library overview

Here is a snippet allowing to list the last modified artists in the media library:

    #!/usr/bin/env python3
    # coding: utf-8
    import musicpd

    def main():
        cli = musicpd.MPDClient()
        cli.connect()
        # Gets files count in the library
        nb_files = int(cli.stats()['songs'])
        # Gets the last 100 files modified
        files = cli.search('file', '', 'sort', 'Last-Modified', 'window', (nb_files-100,))
        # Print last modified artists in media library
        print(' / '.join({f.get('albumartist') for f in files}))
        cli.disconnect()

    # Script starts here
    if __name__ == '__main__':
        main()

## Build documentation

    # Get the source
    git clone https://gitlab.com/kaliko/python-musicpd.git && cd python-musicpd
    # Installs sphinx if needed
    python3 -m venv venv && . ./venv/bin/activate
    pip install sphinx
    # Call sphinx
    sphinx-build -d ./doc/build/doctrees doc/source -b html ./doc/build/html

## Contents

- Music Player Daemon client module
- Using the client library
  - Introduction
  - Environment variables
  - Default settings
  - Context manager
  - Command lists
  - Ranges
  - Iterators
  - Idle prefixed commands
  - Fetching binary content (cover art)
  - Socket timeout
  - Exceptions
- musicpd namespace
  - `VERSION`
  - `CONNECTION_TIMEOUT`
  - `SOCKET_TIMEOUT`
  - `iterator_wrapper()`
  - `MPDError`
  - `ConnectionError`
  - `ProtocolError`
  - `CommandError`
  - `MPDClient`
- Examples
  - Plain examples
  - Object Oriented example
  - Dealing with Exceptions
- Available commands
  - Querying MPD’s status
  - Playback Option
  - Controlling playback
  - The Queue
  - Stored playlists
  - The music database
  - Mounts and neighbors
  - Stickers
  - Connection settings
  - Partition Commands
  - Audio output devices
  - Reflection
  - Client to Client
- Contributing
  - Git Workflow
  - Coding

## Indices and tables

- Index

- Search Page