mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-29 21:27:05 +02:00
Use mbtypes.ISRC type
This commit is contained in:
parent
ad1644672c
commit
13eb8342ab
7 changed files with 16 additions and 11 deletions
|
@ -68,7 +68,7 @@ func TestListenBrainzListenAsListen(t *testing.T) {
|
|||
assert.Equal(t, mbtypes.MBID("c0a1fc94-5f04-4a5f-bc09-e5de0c49cd12"), listen.RecordingMBID)
|
||||
assert.Equal(t, mbtypes.MBID("d7f22677-9803-4d21-ba42-081b633a6f68"), listen.ReleaseMBID)
|
||||
assert.Equal(t, mbtypes.MBID("80aca1ee-aa51-41be-9f75-024710d92ff4"), listen.ReleaseGroupMBID)
|
||||
assert.Equal(t, "DES561620801", listen.ISRC)
|
||||
assert.Equal(t, mbtypes.ISRC("DES561620801"), listen.ISRC)
|
||||
assert.Equal(t, lbListen.TrackMetadata.AdditionalInfo["foo"], listen.AdditionalInfo["foo"])
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"go.uploadedlobster.com/mbtypes"
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
|
@ -158,8 +159,8 @@ func (t Track) DiscNumber() int {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (t Track) ISRC() string {
|
||||
return tryGetValueOrEmpty[string](t.AdditionalInfo, "isrc")
|
||||
func (t Track) ISRC() mbtypes.ISRC {
|
||||
return mbtypes.ISRC(tryGetValueOrEmpty[string](t.AdditionalInfo, "isrc"))
|
||||
}
|
||||
|
||||
func (t Track) RecordingMBID() string {
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/mbtypes"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/listenbrainz"
|
||||
)
|
||||
|
||||
|
@ -131,10 +132,10 @@ func TestTrackTrackNumberString(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTrackIsrc(t *testing.T) {
|
||||
expected := "TCAEJ1934417"
|
||||
expected := mbtypes.ISRC("TCAEJ1934417")
|
||||
track := listenbrainz.Track{
|
||||
AdditionalInfo: map[string]any{
|
||||
"isrc": expected,
|
||||
"isrc": string(expected),
|
||||
},
|
||||
}
|
||||
assert.Equal(t, expected, track.ISRC())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue