Rate current track

This commit is contained in:
Dan Jones 2023-08-27 20:07:00 -05:00
commit 83dc41cb8e
4 changed files with 83 additions and 9 deletions

View file

@ -10,6 +10,7 @@ type Song struct {
Path string
Attrs mpd.Attrs
stickers []mpd.Sticker
// @todo refactor as a map so there's no dupes
}
func newSong(attrs mpd.Attrs) *Song {
@ -52,8 +53,8 @@ func (s *Song) GetSticker(name string) string {
return sticker.Name == name
})
if ret != nil && len(ret) > 0 {
first := ret[0]
return first.Value
last := ret[len(ret)-1]
return last.Value
}
}
@ -70,3 +71,15 @@ func (s *Song) GetSticker(name string) string {
return found.Value
}
func (s *Song) AddSticker(name, value string) error {
ret := conn.StickerSet(s.Path, name, value)
if ret == nil {
if s.stickers == nil || len(s.stickers) == 0 {
s.GetStickers()
} else {
s.stickers = append(s.stickers, mpd.Sticker{Name: name, Value: value})
}
}
return ret
}