MPD Client

class sima.mpdclient.MPD(config)[source]

Bases: musicpd.MPDClient

Player instance inheriting from MPDClient (python-musicpd).

Some methods are overridden to format objects as sima.lib.track.Track for instance, other are calling parent class directly through super(). cf. MPD.__getattr__

Note

  • find methods are looking for exact match of the object provided attributes in MPD music library

  • search methods are looking for exact match + fuzzy match.

add(payload)[source]

Overriding MPD’s add method to accept Track objects

Parameters

payload (Track,list) – Either a single track or a list of it

clean()[source]

Clean blocking event (idle) and pending commands

connect()[source]

Overriding explicitly MPDClient.connect()

disconnect()[source]

Overriding explicitly MPDClient.disconnect()

find_tracks(what)[source]
Find tracks for a specific artist or album
>>> player.find_tracks(Artist('Nirvana'))
>>> player.find_tracks(Album('In Utero', artist=Artist('Nirvana'))
Parameters

what (Artist,Album) – Artist or Album to fetch track from

Returns

A list of track objects

Return type

list(Track)

monitor()[source]

Monitor player for change Returns a list a events among:

  • database player media library has changed

  • playlist playlist modified

  • options player options changed: repeat mode, etc…

  • player player state changed: paused, stopped, skip track…

  • skipped current track skipped

property playlist

Override deprecated MPD playlist command

search_albums(artist)[source]

Find potential albums for “artist”

  • Fetch all albums for “AlbumArtist” == artist → falls back to “Artist” == artist when no “AlbumArtist” tag is set

  • Tries to filter some mutli-artists album For instance an album by Artist_A may have a track by Artist_B. Then looking for albums for Artist_B wrongly returns this album.

search_track(artist, title)[source]

Fuzzy search of title by an artist

property state

Returns (play|stop|pause)