Skip to content

mpd's lsinfo and gompd's ListInfo return different data: undocumented, removes data #88

@iconoclasthero

Description

@iconoclasthero
$ go run listinfo.go; hr; mpdc lsinfo\ /library/music/test.flac
file: /library/music/test.flac
musicbrainz_albumartistid: 6faa7ca7-0d99-4a5e-bfa6-1fd5037520c6
format: 44100:16:2
genre: Blues, Rock
title: When I Paint My Masterpiece
track: 1
musicbrainz_releasetrackid: bc6db833-f35b-4153-b334-2d8eb78d654e
duration: 371.106
added: 2026-01-24T15:20:47Z
album: Postcards of the Hanging: Grateful Dead Perform the Songs of Bob Dylan
originaldate: 2002-03-19
artist: Grateful Dead
disc: 1
albumartist: Grateful Dead
musicbrainz_trackid: f5f2748b-ce51-4b06-9289-56419d8111c6
musicbrainz_workid: cd141fbd-053f-3e0f-a046-ec60c3104d74
work: When I Paint My Masterpiece
performer: Bob Weir (vocals)
musicbrainz_artistid: 6faa7ca7-0d99-4a5e-bfa6-1fd5037520c6
artistsort: Grateful Dead
composer: Bob Dylan
composersort: Dylan, Bob
time: 371
musicbrainz_albumid: 795c6176-83d9-4905-8663-65b572ce1133
date: 2002-03-19
label: Grateful Dead Records
albumartistsort: Grateful Dead
musicbrainz_releasegroupid: 5564061f-0adc-3f66-973e-0a5c57ba6dfe
last-modified: 2026-01-24T15:20:47Z
########################################################################################################################################
OK MPD 0.24.0
file: /library/music/test.flac
Last-Modified: 2026-01-24T15:20:47Z
Added: 2026-01-24T15:20:47Z
Format: 44100:16:2
Artist: Grateful Dead
Date: 2002-03-19
Disc: 1
Genre: Blues, Rock
Title: When I Paint My Masterpiece
Track: 1
Album: Postcards of the Hanging: Grateful Dead Perform the Songs of Bob Dylan
MUSICBRAINZ_RELEASEGROUPID: 5564061f-0adc-3f66-973e-0a5c57ba6dfe
OriginalDate: 2002-03-19
MUSICBRAINZ_ALBUMID: 795c6176-83d9-4905-8663-65b572ce1133
Label: Grateful Dead Records
Performer: Jerry Garcia (guitar)
Performer: Bob Weir (guitar)
Performer: Mickey Hart (drums (drum set))
Performer: Bill Kreutzmann (drums (drum set))
Performer: Phil Lesh (electric bass guitar)
Performer: Brent Mydland (organ)
Performer: Brent Mydland (keyboard)
Performer: Jerry Garcia (vocals)
Performer: Phil Lesh (vocals)
Performer: Brent Mydland (vocals)
Performer: Bob Weir (vocals)
MUSICBRAINZ_ALBUMARTISTID: 6faa7ca7-0d99-4a5e-bfa6-1fd5037520c6
AlbumArtist: Grateful Dead
AlbumArtistSort: Grateful Dead
MUSICBRAINZ_TRACKID: f5f2748b-ce51-4b06-9289-56419d8111c6
MUSICBRAINZ_ARTISTID: 6faa7ca7-0d99-4a5e-bfa6-1fd5037520c6
ArtistSort: Grateful Dead
MUSICBRAINZ_WORKID: cd141fbd-053f-3e0f-a046-ec60c3104d74
Work: When I Paint My Masterpiece
Composer: Bob Dylan
ComposerSort: Dylan, Bob
MUSICBRAINZ_RELEASETRACKID: bc6db833-f35b-4153-b334-2d8eb78d654e
Time: 371
duration: 371.106
OK

It took me a while to figure out why absolute paths did not need to have the tag names normalized (for case). Eventually I tested just the output of mpdgo's listinfo vs. mpd's lsinfo and found that not only does the former normalize to lowercase for the tag names, it does not output all of the data.

  • ListInfo always lowercases keys.
  • In contrast, the CurrentSong and PlaylistInfo return the tag name case as provided by mpd.
// ListInfo lists the contents of the directory URI using MPD's lsinfo command.
func (c *Client) ListInfo(uri string) ([]Attrs, error) {
	id, err := c.cmd("lsinfo %s", quote(uri))
	if err != nil {
		return nil, err
	}
	c.text.StartResponse(id)
	defer c.text.EndResponse(id)
	attrs := []Attrs{}
	for {
		line, err := c.readLine()
		if err != nil {
			return nil, err
		}
		if line == "OK" {
			break
		}
		if strings.HasPrefix(line, "file: ") ||
			strings.HasPrefix(line, "directory: ") ||
			strings.HasPrefix(line, "playlist: ") {
			attrs = append(attrs, Attrs{})
		}
		i := strings.Index(line, ": ")
		if i < 0 {
			return nil, textproto.ProtocolError("can't parse line: " + line)
		}
		attrs[len(attrs)-1][strings.ToLower(line[0:i])] = line[i+2:]
	}
	return attrs, nil
}

It should be noted that ListInfo, CurrentSong and PlaylistInfo all collapse duplicates. (NB, e.g., the Performers in the mpd output.)

In addition to documenting this behavior, it would be preferable if they were able to return all the data that mpd has access to rather than collapsing duplicates. Also, it's pretty clear that if one is expecting to use the tag names as mpd provides them, you're out of luck with ListInfo; that' data's lost with the strings.ToLower.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions