aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-10-10 13:24:29 -0700
committerFranck Cuny <franck@fcuny.net>2021-10-10 13:24:29 -0700
commite8059bd9a8ea7c1bba29ca947c7c7fa7eedee8cb (patch)
treef32212ac90b1ff1a4baa6b8923ab4af5b4087f2b
parentrecord: add some basic testing (diff)
downloadx-e8059bd9a8ea7c1bba29ca947c7c7fa7eedee8cb.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.
-rw-r--r--internal/scrobbler/scrobbler.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/internal/scrobbler/scrobbler.go b/internal/scrobbler/scrobbler.go
index a31569e..e16458c 100644
--- a/internal/scrobbler/scrobbler.go
+++ b/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)
}