# MPD client class

class `musicpd.``MPDClient`

  MPDClient instance will look for `MPD_HOST`/`MPD_PORT`/`XDG_RUNTIME_DIR` environment variables and set instance attribute `host`, `port` and `pwd` accordingly.

  Then `musicpd.MPDClient.connect` will use `host` and `port` as defaults if not provided as args.

  Cf. `musicpd.MPDClient.connect` for details.

      >>> from os import environ
      >>> environ['MPD_HOST'] = 'pass@mpdhost'
      >>> cli = musicpd.MPDClient()
      >>> cli.pwd == environ['MPD_HOST'].split('@')[0]
      True
      >>> cli.host == environ['MPD_HOST'].split('@')[1]
      True
      >>> # cli.connect() will use host/port as set in MPD_HOST/MPD_PORT

  `connect`(host=None, port=None)

    Connects the MPD server

    Parameters:

    - host (str) – hostname, IP or FQDN (defaults to localhost or socket, see below for details)
    - port (str) – port number (defaults to 6600)

    The connect method honors MPD_HOST/MPD_PORT environment variables.

    Note

    Default host/port

    If host evaluate to `False`
      - use `MPD_HOST` env. var. if set, extract password if present,
      - else looks for a existing file in `${XDG_RUNTIME_DIR:-/run/}/mpd/socket`
      - else set host to `localhost`
    If port evaluate to `False`
      - if `MPD_PORT` env. var. is set, use it for port
      - else use `6600`
  `disconnect`()

    Closes the MPD connection. The client closes the actual socket, it does not use the ‘close’ request from MPD protocol (as suggested in documentation).