mpd

mpd mpc query language


I can't figure out how to properly query mpd using mpc.

For example: I know how to list all albums

mpc list album

But I want to get more than the name.

How can I query mpd for album, path, artist, track number, duration and so on? Preferably in one query but multiple queries are ok as well.

I tried to read the mpc man page and the official documentation of mpd but can't figure it out.


Solution

  • mpc does not (as of this writing, v0.27-1) have any commands that give you all the metadata for a song, identified by uri. It's surprising that it doesn't, but it doesn't.

    The MPD communication protocol, however, does return full information about each song.

    If I issue mpc current I only get this response:

    Afro Celt Sound System - Release
    

    However, if I send the MPD (not MPC) command currentsong then I get this response from MPD:

    file: gavin/Compilations/Volume 2 _ Release/01 Release.m4a
    Last-Modified: 2005-03-02T14:16:51Z
    Artist: Afro Celt Sound System
    Album: Volume 2 : Release
    Title: Release
    Track: 1/11
    Genre:World
    Date: 1999
    Composer: Simon Emerson, James McNally, Iarla O Lionaird, Martin Russell & Sinead O'Connor/Sinéad O'Connor
    Disc: 1/1
    Time: 456
    Pos: 0
    Id: 53616
    

    If I send the MPD command playlistid 49312 I get this response:

    file: gavin/ATB/Future Memories/16 Missing 1.m4a
    Last-Modified: 2013-11-17T21:14:43Z
    Artist: ATB
    Album: Future Memories
    Title: Missing
    Track: 16/29
    Genre: Dance
    Date: 2009-05-01T07:00:00Z
    Composer: Tracey Thorn & Ben Watt
    Disc: 1/1
    AlbumArtist: ATB
    Time: 256
    Pos: 10
    Id: 49312
    

    If I send the command search file surfing I get this response (different songs are delimited by a new file:):

    file: doza/Air/06 Surfing On a Rocket.m4a
    Last-Modified: 2015-11-20T15:56:00Z
    Time: 223
    Artist: Air
    Album: Talkie Walkie
    Title: Surfing On a Rocket
    Track: 6/10
    Genre: Electronic
    Date: 2004-01-26T08:00:00Z
    Disc: 1/1
    AlbumArtist: Air
    file: gavin/Air/Surfing On a Rocket EP/06 Surfing on a rocket (remixed by Joakim).m4a
    Last-Modified: 2015-01-13T15:31:39Z
    Time: 393
    Artist: Air
    Album: Surfing On a Rocket EP
    Title: Surfing on a rocket (remixed by Joakim)
    Track: 6/7
    Genre: Dance
    Date: 2004-09-10T07:00:00Z
    Composer: Jean-Benoit Dunckel & Nicolas Godin
    Disc: 1/1
    AlbumArtist: Air
    file: gavin/The Beach Boys/Greatest Surfing Songs!/02 Little Deuce Coupe.mp3
    Last-Modified: 2009-09-10T04:32:49Z
    Time: 111
    Artist: The Beach Boys
    Title: Little Deuce Coupe
    Album: Greatest Surfing Songs!
    Track: 2
    Genre: Sunshine Pop
    

    And if I send the MPD command listplaylistinfo Thump, I get this response:

    file: gavin/Muse/The 2nd Law (Deluxe Version)/02 Madness.m4a
    Last-Modified: 2013-11-17T22:30:54Z
    Artist: Muse
    Album: The 2nd Law (Deluxe Version)
    Title: Madness
    Track: 2/13
    Genre: Alternative
    Date: 2012-10-01T07:00:00Z
    Disc: 1/1
    AlbumArtist: Muse
    Time: 280
    file: gavin/U2/The Best Of 1990-2000/15 Numb (New Mix).mp3
    Last-Modified: 2003-09-24T14:31:05Z
    Artist: U2
    Title: Numb (New Mix)
    Album: The Best Of 1990-2000
    Track: 15/16
    Date: 2002
    Genre: Rock
    Composer: U2
    Time: 264
    file: gavin/Massive Attack/Mezzanine/03 Teardrop.m4a
    Last-Modified: 2012-09-05T19:38:14Z
    Artist: Massive Attack
    Album: Mezzanine
    Title: Teardrop
    Track: 3/11
    Genre: Electronic
    Date: 1998-04-20T07:00:00Z
    Disc: 1/1
    AlbumArtist: Massive Attack
    Time: 331
    file: gavin/Massive Attack/Mezzanine/01 Angel.m4a
    Last-Modified: 2012-09-05T19:38:17Z
    Artist: Massive Attack
    Album: Mezzanine
    Title: Angel
    Track: 1/11
    Genre: Electronic
    Date: 1998-04-20T07:00:00Z
    Disc: 1/1
    AlbumArtist: Massive Attack
    Time: 380
    file: gavin/Eels/Shrek 2/07 I Need Some Sleep.mp3
    Last-Modified: 2005-01-14T21:24:25Z
    Artist: Eels
    Title: I Need Some Sleep
    Album: Shrek 2
    Track: 7/14
    Date: 2004
    Genre: Soundtrack
    Time: 147
    

    I personally use the ruby-mpd library to provide a convenient interface to communicating with MPD, in a rich, full-featured way.