blob: b9f95a0f27c3956c04af5cb208e403c13c997edf (
plain) (
tree)
|
|
package scrobbler
import (
"strconv"
"time"
"github.com/fhs/gompd/v2/mpd"
"github.com/google/uuid"
)
type Record struct {
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"],
Timestamp: time.Now(),
}
dur, err := strconv.ParseFloat(attrs["duration"], 32)
if err != nil {
return nil, err
}
record.Duration = time.Second * time.Duration(dur)
return &record, nil
}
|