From 807fea547bf8ebd74fcc255ae9bddf933c7a5b1b Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 10 Oct 2021 13:00:38 -0700 Subject: scrobbler: add timestamp to the record When we create a new record, let's capture when this was created. --- tools/mpd-stats/internal/scrobbler/record.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'tools/mpd-stats/internal/scrobbler/record.go') 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) -- cgit 1.4.1