1
0

Added a duration field to Song_ struct.

This commit is contained in:
Alexander Andreev 2023-10-02 01:26:22 +04:00
parent a741e3eb9a
commit c054c3b32e
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -11,6 +11,7 @@ import (
type Song_ struct { type Song_ struct {
Artist string Artist string
Title string Title string
Duration time.Duration
MaxListeners int MaxListeners int
StartAt time.Time StartAt time.Time
} }
@ -23,11 +24,13 @@ func (s *Song_) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct { return json.Marshal(&struct {
Artist string `json:"artist"` Artist string `json:"artist"`
Title string `json:"title"` Title string `json:"title"`
Duration int64 `json:"duration_milliseconds"`
MaxListeners int `json:"listeners"` MaxListeners int `json:"listeners"`
StartAt string `json:"start_at"` StartAt string `json:"start_at"`
}{ }{
Artist: s.Artist, Artist: s.Artist,
Title: s.Title, Title: s.Title,
Duration: s.Duration.Milliseconds(),
MaxListeners: s.MaxListeners, MaxListeners: s.MaxListeners,
StartAt: s.StartAt.UTC().Format(time.RFC3339)}) StartAt: s.StartAt.UTC().Format(time.RFC3339)})
} }