fix(listenbrainz): set track length submission and include submission client details (#424)
* Fixed ListenBrainz track duration submission * Include submission client info in ListenBrainz payload * Extended ListenBrainz test
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"net/http/httputil"
|
||||
"time"
|
||||
|
||||
"go.senan.xyz/gonic"
|
||||
"go.senan.xyz/gonic/db"
|
||||
"go.senan.xyz/gonic/scrobble"
|
||||
)
|
||||
@@ -46,7 +47,8 @@ func (c *Client) Scrobble(user db.User, track scrobble.Track, stamp time.Time, s
|
||||
AdditionalInfo: &AdditionalInfo{
|
||||
TrackNumber: int(track.TrackNumber),
|
||||
RecordingMBID: track.MusicBrainzID,
|
||||
TrackLength: int(track.Duration.Seconds()),
|
||||
Duration: int(track.Duration.Seconds()),
|
||||
SubmissionClient: gonic.Name,
|
||||
},
|
||||
ArtistName: track.Artist,
|
||||
TrackName: track.Track,
|
||||
|
||||
@@ -37,7 +37,14 @@ func TestScrobble(t *testing.T) {
|
||||
|
||||
err := client.Scrobble(
|
||||
db.User{ListenBrainzURL: "https://listenbrainz.org", ListenBrainzToken: "token1"},
|
||||
scrobble.Track{Track: "title", Artist: "artist", Album: "album", TrackNumber: 1},
|
||||
scrobble.Track{
|
||||
Track: "title",
|
||||
Artist: "artist",
|
||||
Album: "album",
|
||||
TrackNumber: 1,
|
||||
Duration: 242 * time.Second,
|
||||
MusicBrainzID: "00000000-0000-0000-0000-000000000000",
|
||||
},
|
||||
time.Unix(1683804525, 0),
|
||||
true,
|
||||
)
|
||||
|
||||
@@ -12,7 +12,8 @@ type (
|
||||
TrackNumber int `json:"tracknumber,omitempty"`
|
||||
TrackMBID string `json:"track_mbid,omitempty"`
|
||||
RecordingMBID string `json:"recording_mbid,omitempty"`
|
||||
TrackLength int `json:"track_length,omitempty"`
|
||||
Duration int `json:"duration,omitempty"`
|
||||
SubmissionClient string `json:"submission_client,omitempty"`
|
||||
}
|
||||
|
||||
TrackMetadata struct {
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
"listened_at": 1683804525,
|
||||
"track_metadata": {
|
||||
"additional_info": {
|
||||
"tracknumber": 1
|
||||
"tracknumber": 1,
|
||||
"duration": 242,
|
||||
"recording_mbid": "00000000-0000-0000-0000-000000000000",
|
||||
"submission_client": "gonic"
|
||||
},
|
||||
"artist_name": "artist",
|
||||
"track_name": "title",
|
||||
|
||||
Reference in New Issue
Block a user