func (t *Track) GetInt(field string) int {
	if field == "TotalTime" {
		return t.Track.GetInt(field)
	}
	if t.group.Field(field) != nil {
		return 0
	}
	return t.Track.GetInt(field)
}
GetInt implements index.Track.
package main
import (
	"encoding/json"
	"tchaik.com/index"
	"tchaik.com/index/attr"
)
type Group struct {
	index.Group
	Key index.Key
}
func (g *Group) MarshalJSON() ([]byte, error) {
	h := group{
		Name:        g.Name(),
		Key:         g.Key,
		TotalTime:   g.Field("TotalTime"),
		Artist:      g.Field("Artist"),
		AlbumArtist: g.Field("AlbumArtist"),
		Composer:    g.Field("Composer"),
		Year:        g.Field("Year"),
		BitRate:     g.Field("BitRate"),
		DiscNumber:  g.Field("DiscNumber"),
		ListStyle:   g.Field("ListStyle"),
		Kind:        g.Field("Kind"),
		ID:          g.Field("ID"),
		Favourite:   g.Field("Favourite"),
		Checklist:   g.Field("Checklist"),
	}
	if c, ok := g.Group.(index.Collection); ok {
		return json.Marshal(buildCollection(h, c))
	}
	for _, t := range g.Tracks() {
		h.Tracks = append(h.Tracks, &Track{
			Track: t,
			group: g,
		})
	}
	return json.Marshal(h)
}
func stringSliceEqual(x, y interface{}) bool {
	if x == nil || y == nil {
		return x == nil && y == nil
	}
	xs := x.([]string)  
	ys := y.([]string)
	if len(xs) != len(ys) {
		return false
	}
	for i, xss := range xs {
		if ys[i] != xss {
			return false
		}
	}
	return true
}
type groupField struct {
	index.Group
	collection index.Collection
}
func (g groupField) Field(field string) interface{} {
	if field == "AlbumArtist" || field == "Artist" {
		if stringSliceEqual(g.Group.Field(field), g.collection.Field(field)) {
			return nil
		}
	}
	return g.Group.Field(field)
}
func buildCollection(h group, c index.Collection) group {
	for _, k := range c.Keys() {
		g := c.Get(k)
		g = index.FirstTrackAttr(attr.Strings("AlbumArtist"), g)
		g = index.CommonGroupAttr([]attr.Interface{attr.Strings("Artist")}, g)
		g = groupField{
			Group:      g,
			collection: c,
		}
		h.Groups = append(h.Groups, group{
			Name:        g.Name(),
			Key:         k,
			AlbumArtist: g.Field("AlbumArtist"),
			Artist:      g.Field("Artist"),
		})
	}
	return h
}
type Track struct {
	index.Track
	group index.Group
}
func (t *Track) GetString(field string) string {
	if field == "ID" || field == "Name" {
		return t.Track.GetString(field)
	}
	if t.group.Field(field) != nil {
		return ""
	}
	return t.Track.GetString(field)
}
func (t *Track) GetStrings(field string) []string {
	if t.group.Field(field) != nil {
		return nil
	}
	return t.Track.GetStrings(field)
}