about summary refs log tree commit diff
path: root/tools/mpd-stats/internal/scrobbler
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-10-10 13:00:38 -0700
committerFranck Cuny <franck@fcuny.net>2022-06-11 14:32:08 -0700
commit807fea547bf8ebd74fcc255ae9bddf933c7a5b1b (patch)
treec21f3622e2296cf15caf5b5bd8cea8a13007ab11 /tools/mpd-stats/internal/scrobbler
parentscrobbler: add interface to the sqlite3 database (diff)
downloadworld-807fea547bf8ebd74fcc255ae9bddf933c7a5b1b.tar.gz
scrobbler: add timestamp to the record
When we create a new record, let's capture when this was created.
Diffstat (limited to 'tools/mpd-stats/internal/scrobbler')
-rw-r--r--tools/mpd-stats/internal/scrobbler/record.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/tools/mpd-stats/internal/scrobbler/record.go b/tools/mpd-stats/internal/scrobbler/record.go
index 927ed27..b9f95a0 100644
--- a/tools/mpd-stats/internal/scrobbler/record.go
+++ b/tools/mpd-stats/internal/scrobbler/record.go
@@ -9,19 +9,21 @@ import (
 )
 
 type Record struct {
-	Id       uuid.UUID
-	Title    string
-	Album    string
-	Artist   string
-	Duration time.Duration
+	Id        uuid.UUID
+	Title     string
+	Album     string
+	Artist    string
+	Duration  time.Duration
+	Timestamp time.Time
 }
 
 func NewRecord(attrs mpd.Attrs) (*Record, error) {
 	record := Record{
-		Id:     uuid.New(),
-		Title:  attrs["Title"],
-		Album:  attrs["Album"],
-		Artist: attrs["Artist"],
+		Id:        uuid.New(),
+		Title:     attrs["Title"],
+		Album:     attrs["Album"],
+		Artist:    attrs["Artist"],
+		Timestamp: time.Now(),
 	}
 
 	dur, err := strconv.ParseFloat(attrs["duration"], 32)