music.mpd
Platypush documentation
music.mpd
- class platypush.plugins.music.mpd.MusicMpdPlugin(host, port=6600)[source]
Bases:
MusicPlugin
This plugin allows you to interact with an MPD/Mopidy music server. MPD (https://www.musicpd.org/) is a flexible server-side protocol/application for handling music collections and playing music, mostly aimed to manage local libraries. Mopidy (https://www.mopidy.com/) is an evolution of MPD, compatible with the original protocol and with support for multiple music sources through plugins (e.g. Spotify, TuneIn, Soundcloud, local files etc.).
NOTE: As of Mopidy 3.0 MPD is an optional interface provided by the
mopidy-mpd
extension. Make sure that you have the extension installed and enabled on your instance to use this plugin with your server.Requires:
python-mpd2 (
pip install python-mpd2
)
- add(resource, position=None)[source]
Add a resource (track, album, artist, folder etc.) to the current playlist
- consume(value=None)[source]
Set consume mode
- Parameters:
value (bool) – If set, set the consume state this value (true/false). Default: None (toggle current state)
- current_track()[source]
- Returns:
The currently played track.
Example response:
output = { "file": "spotify:track:7CO5ADlDN3DcR2pwlnB14P", "time": "255", "artist": "Elbow", "album": "Little Fictions", "title": "Kindling", "date": "2017", "track": "10", "pos": "9", "id": "3061", "albumartist": "Elbow", "x-albumuri": "spotify:album:6q5KhDhf9BZkoob7uAnq19" }
- currentsong()[source]
Legacy alias for
current_track()
.
- find(filter: dict, *args, **kwargs)[source]
Find in the database/library by filter.
- Parameters:
filter – Search filter (e.g.
{"artist": "Led Zeppelin", "album": "IV"}
)- Returns:
list[dict]
- findadd(filter: dict, *args, **kwargs)[source]
Find in the database/library by filter and add to the current playlist.
- Parameters:
filter – Search filter (e.g.
{"artist": "Led Zeppelin", "album": "IV"}
)- Returns:
list[dict]
- get_playlists()[source]
- Returns:
The playlists available on the server as a list of dicts.
Example response:
output = [ { "playlist": "Rock", "last-modified": "2018-06-25T21:28:19Z" }, { "playlist": "Jazz", "last-modified": "2018-06-24T22:28:29Z" }, { # ... } ]
- listplaylists()[source]
Deprecated alias for
playlists()
.
- play(resource=None)[source]
Play a resource by path/URI
- Parameters:
resource (str) – Resource path/URI
- play_pos(pos)[source]
Play a track in the current playlist by position number
- Parameters:
pos – Position number
- playlist_move(playlist, from_pos, to_pos)[source]
Change the position of a track in the specified playlist.
- playlistadd(name, uri)[source]
Deprecated alias for
add_to_playlist()
.
- playlistclear(name)[source]
Clears all the elements from the specified playlist
- Parameters:
name (str) – Playlist name
- playlistdelete(name, pos)[source]
Deprecated alias for
remove_from_playlist()
.
- playlistinfo()[source]
- Returns:
The tracks in the current playlist as a list of dicts.
Example output:
output = [ { "file": "spotify:track:79VtgIoznishPUDWO7Kafu", "time": "355", "artist": "Elbow", "album": "Little Fictions", "title": "Trust the Sun", "date": "2017", "track": "3", "pos": "10", "id": "3062", "albumartist": "Elbow", "x-albumuri": "spotify:album:6q5KhDhf9BZkoob7uAnq19" }, { "file": "spotify:track:3EzTre0pxmoMYRuhJKMHj6", "time": "219", "artist": "Elbow", "album": "Little Fictions", "title": "Gentle Storm", "date": "2017", "track": "2", "pos": "11", "id": "3063", "albumartist": "Elbow", "x-albumuri": "spotify:album:6q5KhDhf9BZkoob7uAnq19" }, ]
- playlistmove(name, from_pos, to_pos)[source]
Deprecated alias for
playlist_move()
.
- plchanges(version)[source]
Show what has changed on the current playlist since a specified playlist version number.
- Parameters:
version (int) – Version number
- Returns:
A list of dicts representing the songs being added since the specified version
- random(value=None)[source]
Set random mode
- Parameters:
value (bool) – If set, set the random state this value (true/false). Default: None (toggle current state)
- rename(name, new_name)[source]
Rename a playlist
- Parameters:
name (str) – Original playlist name
new_name – New playlist name
- repeat(value=None)[source]
Set repeat mode
- Parameters:
value (bool) – If set, set the repeat state this value (true/false). Default: None (toggle current state)
- save(name)[source]
Save the current tracklist to a new playlist with the specified name
- Parameters:
name (str) – Name of the playlist
- search(query: Optional[Union[str, dict]] = None, filter: Optional[dict] = None, *args, **kwargs)[source]
Free search by filter.
- Parameters:
query – Free-text query or search structured filter (e.g.
{"artist": "Led Zeppelin", "album": "IV"}
).filter – Structured search filter (e.g.
{"artist": "Led Zeppelin", "album": "IV"}
) - same asquery
, it’s still here for back-compatibility reasons.
- Returns:
list[dict]
- searchadd(filter, *args, **kwargs)[source]
Free search by filter and add the results to the current playlist.
- Parameters:
filter – Search filter (e.g.
{"artist": "Led Zeppelin", "album": "IV"}
)- Returns:
list[dict]
- searchaddplaylist(name)[source]
Search and add a playlist by (partial or full) name
- Parameters:
name (str) – Playlist name, can be partial
- seek(position)[source]
Seek to the specified position
- Parameters:
position – Seek position in seconds, or delta string (e.g. ‘+15’ or ‘-15’) to indicate a seek relative to the current position :type position: int
- seekcur(value)[source]
Seek to the specified position (DEPRECATED, use
seek()
instead).- Parameters:
value – Seek position in seconds, or delta string (e.g. ‘+15’ or ‘-15’) to indicate a seek relative to the current position :type value: int
- setvol(vol)[source]
Set the volume (DEPRECATED, use
set_volume()
instead).- Parameters:
vol (int) – Volume value (range: 0-100)
- single(value=None)[source]
Set single mode
- Parameters:
value (bool) – If set, set the consume state this value (true/false). Default: None (toggle current state)
- status()[source]
- Returns:
The current state.
Example response:
output = { "volume": "9", "repeat": "0", "random": "0", "single": "0", "consume": "0", "playlist": "52", "playlistlength": "14", "xfade": "0", "state": "play", "song": "9", "songid": "3061", "nextsong": "10", "nextsongid": "3062", "time": "161:255", "elapsed": "161.967", "bitrate": "320" }