piripherals.mpd module¶
-
class
piripherals.mpd.
MPD
(maxvol=100, *args, **kwargs)[source]¶ Bases:
object
Wrapper for MPDClient that adds
- automatic reconnect on connection loss, see issue64.
- custom methods
- volume limit
It supports all methods of
MPDClient
.Parameters: - maxvol (int) – volume limit
- *args – args for
MPDClient
- **kwargs – kwargs for
MPDClient
-
connect
(*args, **kwargs)[source]¶ establish connection
disconnects if already connected, host and port are stored, will reconnect automatically if connection is lost
All parameters are passed to
MPDClient.connect()
.Parameters: - host (str) – hostname/ip/socket
- port (int) – port, usually 6600
-
del_playlist
(name)[source]¶ delete playlist
if playlist exists, this does nothing
Parameters: name (str) – name of the playlist to delete
-
has_playlist
(name)[source]¶ check for playlist
Parameters: name (str) – name of the playlist to look for Returns: true if playlist exists Return type: bool
-
load_playlist
(name)[source]¶ load a playlist
- replaces current playlist with the named playlist
- if the given playlist does not exists, this does nothing
Parameters: name (str) – name of the playlist to load
-
class
piripherals.mpd.
MPDPlaylist
(mpd, field='title')[source]¶ Bases:
object
the current playlist
Parameters: - mpd (MPD) – MPD instance to get the playlist from
- field (str) – metadata field to look for when getting metadata for an playlist entry. If this field is not present, play the track to retrieve the metadata, then switch back to previous state
-
find_next
(field='album')[source]¶ find next song with different field
Find the next song, where
field
has a different value than the currently playing song. Withfield='album'
, this gets the beginning of the next album.If there is only a single album in the playlist or the currently playing song is of the last album,
None
is returned.Returns: # of playlist entry or None Return type: int
-
find_prev
(field='album')[source]¶ find previous song with different field
Find the previous song, where
field
has a different value than the currently playing song. Withfield='album'
, this gets the beginning of the previous album.If there is only a single album in the playlist or the currently playing song is of the first album,
None
is returned.Returns: # of playlist entry or None Return type: int