diff options
author | Franck Cuny <franck@fcuny.net> | 2021-10-10 13:24:29 -0700 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2022-06-11 14:32:08 -0700 |
commit | 6dcf9a1ac37eea734767756c0c1cee6b3974f676 (patch) | |
tree | 0635d0c8aa9ea9ce0d752d34a964b1a37821f31a /tools/mpd-stats/internal/scrobbler | |
parent | record: add some basic testing (diff) | |
download | world-6dcf9a1ac37eea734767756c0c1cee6b3974f676.tar.gz |
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.
Diffstat (limited to 'tools/mpd-stats/internal/scrobbler')
-rw-r--r-- | tools/mpd-stats/internal/scrobbler/scrobbler.go | 4 |
1 files changed, 1 insertions, 3 deletions
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) } |