Example #1
0
// getListing stores other tracks from same folder as current track
func getListing(conn *mpd.Client, s *Status) {
	song, _ := conn.CurrentSong()
	filename := path.Base(song["file"])
	directory := path.Dir(song["file"])
	thisDir, _ := conn.ListInfo(directory)
	var listing = make([]NowList, len(thisDir))

	for i := 0; i < len(thisDir); i++ {
		m := thisDir[i]
		p := m["file"]
		t := m["title"]
		d := path.Dir(p)
		f := path.Base(p)
		if f == "." || f == "" {
			continue
		}
		if t != "" {
			if f == filename {
				listing[i].Current = true
				listing[i].Album = m["album"]
			}
			listing[i].Artist = m["artist"]
			listing[i].Label = t
		} else {
			if f == filename {
				listing[i].Current = true
				listing[i].Album = d
			}
			listing[i].Artist = m["artist"]
			listing[i].Label = f
		}
	}
	s.List = listing
}