From 6dcf9a1ac37eea734767756c0c1cee6b3974f676 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 10 Oct 2021 13:24:29 -0700 Subject: scrobbler: use helper function EqualAttrs To compare the current attributes with the current record, we can use the helper `EqualAttrs` which will tell us if we need to create a new record or not. --- tools/mpd-stats/internal/scrobbler/scrobbler.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tools/mpd-stats/internal') diff --git a/tools/mpd-stats/internal/scrobbler/scrobbler.go b/tools/mpd-stats/internal/scrobbler/scrobbler.go index a31569e..e16458c 100644 --- a/tools/mpd-stats/internal/scrobbler/scrobbler.go +++ b/tools/mpd-stats/internal/scrobbler/scrobbler.go @@ -54,13 +54,12 @@ func (s *Scrobbler) Run() error { if err != nil { log.Fatalf("could not create a log: %v", err) } - log.Printf("we're playing %s/%s/%s [%s]\n", currentRecord.Artist, currentRecord.Album, currentRecord.Title, currentRecord.Duration) previousRecord = currentRecord s.save(currentRecord) continue } - if currentRecord.Title != attrs["Title"] || currentRecord.Artist != attrs["Artist"] || currentRecord.Album != attrs["Album"] { + if !currentRecord.EqualAttrs(attrs) { currentRecord, err = NewRecord(attrs) if err != nil { log.Fatalf("could not create a log: %v", err) @@ -68,7 +67,6 @@ func (s *Scrobbler) Run() error { } if currentRecord.Id != previousRecord.Id { - log.Printf("we're playing %s/%s/%s [%s]\n", currentRecord.Artist, currentRecord.Album, currentRecord.Title, currentRecord.Duration) previousRecord = currentRecord s.save(currentRecord) } -- cgit 1.4.1