diff --git a/internal/backends/listenbrainz/listenbrainz_test.go b/internal/backends/listenbrainz/listenbrainz_test.go index d6d577f..ddeac01 100644 --- a/internal/backends/listenbrainz/listenbrainz_test.go +++ b/internal/backends/listenbrainz/listenbrainz_test.go @@ -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"]) } diff --git a/internal/backends/listenbrainz/models.go b/internal/backends/listenbrainz/models.go index e86ce9d..833acd5 100644 --- a/internal/backends/listenbrainz/models.go +++ b/internal/backends/listenbrainz/models.go @@ -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 { diff --git a/internal/backends/listenbrainz/models_test.go b/internal/backends/listenbrainz/models_test.go index 55e5267..f10f635 100644 --- a/internal/backends/listenbrainz/models_test.go +++ b/internal/backends/listenbrainz/models_test.go @@ -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()) diff --git a/internal/backends/spotify/models.go b/internal/backends/spotify/models.go index e80eccc..a22de21 100644 --- a/internal/backends/spotify/models.go +++ b/internal/backends/spotify/models.go @@ -22,6 +22,8 @@ THE SOFTWARE. package spotify +import "go.uploadedlobster.com/mbtypes" + type TracksResult struct { Href string `json:"href"` Limit int `json:"limit"` @@ -98,9 +100,9 @@ type Artist struct { } type ExternalIds struct { - ISRC string `json:"isrc"` - EAN string `json:"ean"` - UPC string `json:"upc"` + ISRC mbtypes.ISRC `json:"isrc"` + EAN string `json:"ean"` + UPC string `json:"upc"` } type ExternalUrls struct { diff --git a/internal/backends/spotify/spotify_test.go b/internal/backends/spotify/spotify_test.go index bd7ff58..1aa7e87 100644 --- a/internal/backends/spotify/spotify_test.go +++ b/internal/backends/spotify/spotify_test.go @@ -26,6 +26,7 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uploadedlobster.com/mbtypes" "go.uploadedlobster.com/scotty/internal/backends/spotify" "go.uploadedlobster.com/scotty/internal/config" ) @@ -59,7 +60,7 @@ func TestSpotifyListenAsListen(t *testing.T) { assert.Equal(t, []string{"Dool"}, listen.ArtistNames) assert.Equal(t, 5, listen.TrackNumber) assert.Equal(t, 1, listen.DiscNumber) - assert.Equal(t, "DES561620801", listen.ISRC) + assert.Equal(t, mbtypes.ISRC("DES561620801"), listen.ISRC) info := listen.AdditionalInfo assert.Equal(t, "spotify.com", info["music_service"]) assert.Equal(t, "https://open.spotify.com/track/2JKUgGuXK3dEvyuIJ4Yj2V", info["origin_url"]) diff --git a/internal/models/models.go b/internal/models/models.go index 39ae236..0d5abf2 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -44,7 +44,7 @@ type Track struct { TrackNumber int DiscNumber int Duration time.Duration - ISRC string + ISRC mbtypes.ISRC RecordingMBID mbtypes.MBID ReleaseMBID mbtypes.MBID ReleaseGroupMBID mbtypes.MBID diff --git a/internal/models/models_test.go b/internal/models/models_test.go index 0deaefa..5395610 100644 --- a/internal/models/models_test.go +++ b/internal/models/models_test.go @@ -53,7 +53,7 @@ func TestTrackFillAdditionalInfo(t *testing.T) { TrackNumber: 5, DiscNumber: 1, Duration: time.Duration(413787 * time.Millisecond), - ISRC: "DES561620801", + ISRC: mbtypes.ISRC("DES561620801"), Tags: []string{"rock", "psychedelic rock"}, } track.FillAdditionalInfo()