MPD client class¶
-
class
musicpd.
MPDClient
[source] MPDClient instance will look for
MPD_HOST
/MPD_PORT
/XDG_RUNTIME_DIR
environment variables and set instance attributehost
,port
andpwd
accordingly.Then
musicpd.MPDClient.connect
will usehost
andport
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
Variables: - host (str) – host used with the current connection
- port (str) – port used with the current connection
- pwd (str) –
password detected in
MPD_HOST
environment variableWarning
Instance attribute host/port/pwd
While
musicpd.MPDClient().host
andmusicpd.MPDClient().port
keep track of current connection host and port,musicpd.MPDClient().pwd
in only holding the password as extracted fromMPD_HOST
environment variable.Calling
musicpd.MPDClient().password()
with a new password won’t updatemusicpd.MPDClient().pwd
value.
-
connect
(host=None, port=None)[source] Connects the MPD server
Parameters: The connect method honors MPD_HOST/MPD_PORT environment variables.
Note
Default host/port
-
disconnect
()[source] Closes the MPD connection. The client closes the actual socket, it does not use the ‘close’ request from MPD protocol (as suggested in documentation).