diff --git a/api/teal/cbor_gen.go b/api/teal/cbor_gen.go index 2a72b8a..2509d87 100644 --- a/api/teal/cbor_gen.go +++ b/api/teal/cbor_gen.go @@ -49,11 +49,11 @@ func (t *FeedPlay) MarshalCBOR(w io.Writer) error { fieldCount-- } - if t.MusicServiceBaseDomain == nil { + if t.MusicServiceUri == nil { fieldCount-- } - if t.OriginUrl == nil { + if t.OriginUri == nil { fieldCount-- } @@ -205,33 +205,33 @@ func (t *FeedPlay) MarshalCBOR(w io.Writer) error { } - // t.OriginUrl (string) (string) - if t.OriginUrl != nil { + // t.OriginUri (string) (string) + if t.OriginUri != nil { - if len("originUrl") > 1000000 { - return xerrors.Errorf("Value in field \"originUrl\" was too long") + if len("originUri") > 1000000 { + return xerrors.Errorf("Value in field \"originUri\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("originUrl"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("originUri"))); err != nil { return err } - if _, err := cw.WriteString(string("originUrl")); err != nil { + if _, err := cw.WriteString(string("originUri")); err != nil { return err } - if t.OriginUrl == nil { + if t.OriginUri == nil { if _, err := cw.Write(cbg.CborNull); err != nil { return err } } else { - if len(*t.OriginUrl) > 1000000 { - return xerrors.Errorf("Value in field t.OriginUrl was too long") + if len(*t.OriginUri) > 1000000 { + return xerrors.Errorf("Value in field t.OriginUri was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.OriginUrl))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.OriginUri))); err != nil { return err } - if _, err := cw.WriteString(string(*t.OriginUrl)); err != nil { + if _, err := cw.WriteString(string(*t.OriginUri)); err != nil { return err } } @@ -492,6 +492,38 @@ func (t *FeedPlay) MarshalCBOR(w io.Writer) error { } } + // t.MusicServiceUri (string) (string) + if t.MusicServiceUri != nil { + + if len("musicServiceUri") > 1000000 { + return xerrors.Errorf("Value in field \"musicServiceUri\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("musicServiceUri"))); err != nil { + return err + } + if _, err := cw.WriteString(string("musicServiceUri")); err != nil { + return err + } + + if t.MusicServiceUri == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.MusicServiceUri) > 1000000 { + return xerrors.Errorf("Value in field t.MusicServiceUri was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.MusicServiceUri))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.MusicServiceUri)); err != nil { + return err + } + } + } + // t.TrackDiscriminant (string) (string) if t.TrackDiscriminant != nil { @@ -587,38 +619,6 @@ func (t *FeedPlay) MarshalCBOR(w io.Writer) error { } } } - - // t.MusicServiceBaseDomain (string) (string) - if t.MusicServiceBaseDomain != nil { - - if len("musicServiceBaseDomain") > 1000000 { - return xerrors.Errorf("Value in field \"musicServiceBaseDomain\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("musicServiceBaseDomain"))); err != nil { - return err - } - if _, err := cw.WriteString(string("musicServiceBaseDomain")); err != nil { - return err - } - - if t.MusicServiceBaseDomain == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.MusicServiceBaseDomain) > 1000000 { - return xerrors.Errorf("Value in field t.MusicServiceBaseDomain was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.MusicServiceBaseDomain))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.MusicServiceBaseDomain)); err != nil { - return err - } - } - } return nil } @@ -647,7 +647,7 @@ func (t *FeedPlay) UnmarshalCBOR(r io.Reader) (err error) { n := extra - nameBuf := make([]byte, 22) + nameBuf := make([]byte, 21) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -780,8 +780,8 @@ func (t *FeedPlay) UnmarshalCBOR(r io.Reader) (err error) { t.Duration = (*int64)(&extraI) } } - // t.OriginUrl (string) (string) - case "originUrl": + // t.OriginUri (string) (string) + case "originUri": { b, err := cr.ReadByte() @@ -798,7 +798,7 @@ func (t *FeedPlay) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.OriginUrl = (*string)(&sval) + t.OriginUri = (*string)(&sval) } } // t.TrackMbId (string) (string) @@ -997,8 +997,8 @@ func (t *FeedPlay) UnmarshalCBOR(r io.Reader) (err error) { t.RecordingMbId = (*string)(&sval) } } - // t.TrackDiscriminant (string) (string) - case "trackDiscriminant": + // t.MusicServiceUri (string) (string) + case "musicServiceUri": { b, err := cr.ReadByte() @@ -1015,11 +1015,11 @@ func (t *FeedPlay) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.TrackDiscriminant = (*string)(&sval) + t.MusicServiceUri = (*string)(&sval) } } - // t.ReleaseDiscriminant (string) (string) - case "releaseDiscriminant": + // t.TrackDiscriminant (string) (string) + case "trackDiscriminant": { b, err := cr.ReadByte() @@ -1036,11 +1036,11 @@ func (t *FeedPlay) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.ReleaseDiscriminant = (*string)(&sval) + t.TrackDiscriminant = (*string)(&sval) } } - // t.SubmissionClientAgent (string) (string) - case "submissionClientAgent": + // t.ReleaseDiscriminant (string) (string) + case "releaseDiscriminant": { b, err := cr.ReadByte() @@ -1057,11 +1057,11 @@ func (t *FeedPlay) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.SubmissionClientAgent = (*string)(&sval) + t.ReleaseDiscriminant = (*string)(&sval) } } - // t.MusicServiceBaseDomain (string) (string) - case "musicServiceBaseDomain": + // t.SubmissionClientAgent (string) (string) + case "submissionClientAgent": { b, err := cr.ReadByte() @@ -1078,7 +1078,7 @@ func (t *FeedPlay) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.MusicServiceBaseDomain = (*string)(&sval) + t.SubmissionClientAgent = (*string)(&sval) } } @@ -1946,11 +1946,11 @@ func (t *FeedDefs_PlayView) MarshalCBOR(w io.Writer) error { fieldCount-- } - if t.MusicServiceBaseDomain == nil { + if t.MusicServiceUri == nil { fieldCount-- } - if t.OriginUrl == nil { + if t.OriginUri == nil { fieldCount-- } @@ -2072,33 +2072,33 @@ func (t *FeedDefs_PlayView) MarshalCBOR(w io.Writer) error { } - // t.OriginUrl (string) (string) - if t.OriginUrl != nil { + // t.OriginUri (string) (string) + if t.OriginUri != nil { - if len("originUrl") > 1000000 { - return xerrors.Errorf("Value in field \"originUrl\" was too long") + if len("originUri") > 1000000 { + return xerrors.Errorf("Value in field \"originUri\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("originUrl"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("originUri"))); err != nil { return err } - if _, err := cw.WriteString(string("originUrl")); err != nil { + if _, err := cw.WriteString(string("originUri")); err != nil { return err } - if t.OriginUrl == nil { + if t.OriginUri == nil { if _, err := cw.Write(cbg.CborNull); err != nil { return err } } else { - if len(*t.OriginUrl) > 1000000 { - return xerrors.Errorf("Value in field t.OriginUrl was too long") + if len(*t.OriginUri) > 1000000 { + return xerrors.Errorf("Value in field t.OriginUri was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.OriginUrl))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.OriginUri))); err != nil { return err } - if _, err := cw.WriteString(string(*t.OriginUrl)); err != nil { + if _, err := cw.WriteString(string(*t.OriginUri)); err != nil { return err } } @@ -2287,65 +2287,65 @@ func (t *FeedDefs_PlayView) MarshalCBOR(w io.Writer) error { } } - // t.SubmissionClientAgent (string) (string) - if t.SubmissionClientAgent != nil { + // t.MusicServiceUri (string) (string) + if t.MusicServiceUri != nil { - if len("submissionClientAgent") > 1000000 { - return xerrors.Errorf("Value in field \"submissionClientAgent\" was too long") + if len("musicServiceUri") > 1000000 { + return xerrors.Errorf("Value in field \"musicServiceUri\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("submissionClientAgent"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("musicServiceUri"))); err != nil { return err } - if _, err := cw.WriteString(string("submissionClientAgent")); err != nil { + if _, err := cw.WriteString(string("musicServiceUri")); err != nil { return err } - if t.SubmissionClientAgent == nil { + if t.MusicServiceUri == nil { if _, err := cw.Write(cbg.CborNull); err != nil { return err } } else { - if len(*t.SubmissionClientAgent) > 1000000 { - return xerrors.Errorf("Value in field t.SubmissionClientAgent was too long") + if len(*t.MusicServiceUri) > 1000000 { + return xerrors.Errorf("Value in field t.MusicServiceUri was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SubmissionClientAgent))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.MusicServiceUri))); err != nil { return err } - if _, err := cw.WriteString(string(*t.SubmissionClientAgent)); err != nil { + if _, err := cw.WriteString(string(*t.MusicServiceUri)); err != nil { return err } } } - // t.MusicServiceBaseDomain (string) (string) - if t.MusicServiceBaseDomain != nil { + // t.SubmissionClientAgent (string) (string) + if t.SubmissionClientAgent != nil { - if len("musicServiceBaseDomain") > 1000000 { - return xerrors.Errorf("Value in field \"musicServiceBaseDomain\" was too long") + if len("submissionClientAgent") > 1000000 { + return xerrors.Errorf("Value in field \"submissionClientAgent\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("musicServiceBaseDomain"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("submissionClientAgent"))); err != nil { return err } - if _, err := cw.WriteString(string("musicServiceBaseDomain")); err != nil { + if _, err := cw.WriteString(string("submissionClientAgent")); err != nil { return err } - if t.MusicServiceBaseDomain == nil { + if t.SubmissionClientAgent == nil { if _, err := cw.Write(cbg.CborNull); err != nil { return err } } else { - if len(*t.MusicServiceBaseDomain) > 1000000 { - return xerrors.Errorf("Value in field t.MusicServiceBaseDomain was too long") + if len(*t.SubmissionClientAgent) > 1000000 { + return xerrors.Errorf("Value in field t.SubmissionClientAgent was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.MusicServiceBaseDomain))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SubmissionClientAgent))); err != nil { return err } - if _, err := cw.WriteString(string(*t.MusicServiceBaseDomain)); err != nil { + if _, err := cw.WriteString(string(*t.SubmissionClientAgent)); err != nil { return err } } @@ -2378,7 +2378,7 @@ func (t *FeedDefs_PlayView) UnmarshalCBOR(r io.Reader) (err error) { n := extra - nameBuf := make([]byte, 22) + nameBuf := make([]byte, 21) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -2500,8 +2500,8 @@ func (t *FeedDefs_PlayView) UnmarshalCBOR(r io.Reader) (err error) { t.Duration = (*int64)(&extraI) } } - // t.OriginUrl (string) (string) - case "originUrl": + // t.OriginUri (string) (string) + case "originUri": { b, err := cr.ReadByte() @@ -2518,7 +2518,7 @@ func (t *FeedDefs_PlayView) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.OriginUrl = (*string)(&sval) + t.OriginUri = (*string)(&sval) } } // t.TrackMbId (string) (string) @@ -2637,8 +2637,8 @@ func (t *FeedDefs_PlayView) UnmarshalCBOR(r io.Reader) (err error) { t.RecordingMbId = (*string)(&sval) } } - // t.SubmissionClientAgent (string) (string) - case "submissionClientAgent": + // t.MusicServiceUri (string) (string) + case "musicServiceUri": { b, err := cr.ReadByte() @@ -2655,11 +2655,11 @@ func (t *FeedDefs_PlayView) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.SubmissionClientAgent = (*string)(&sval) + t.MusicServiceUri = (*string)(&sval) } } - // t.MusicServiceBaseDomain (string) (string) - case "musicServiceBaseDomain": + // t.SubmissionClientAgent (string) (string) + case "submissionClientAgent": { b, err := cr.ReadByte() @@ -2676,7 +2676,7 @@ func (t *FeedDefs_PlayView) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.MusicServiceBaseDomain = (*string)(&sval) + t.SubmissionClientAgent = (*string)(&sval) } } diff --git a/api/teal/feeddefs.go b/api/teal/feeddefs.go index 495aef8..6fe0a0c 100644 --- a/api/teal/feeddefs.go +++ b/api/teal/feeddefs.go @@ -20,11 +20,11 @@ type FeedDefs_PlayView struct { Duration *int64 `json:"duration,omitempty" cborgen:"duration,omitempty"` // isrc: The ISRC code associated with the recording Isrc *string `json:"isrc,omitempty" cborgen:"isrc,omitempty"` - // musicServiceBaseDomain: The base domain of the music service. e.g. music.apple.com, tidal.com, spotify.com. Defaults to 'local' if not provided. - MusicServiceBaseDomain *string `json:"musicServiceBaseDomain,omitempty" cborgen:"musicServiceBaseDomain,omitempty"` - // originUrl: The URL associated with this track - OriginUrl *string `json:"originUrl,omitempty" cborgen:"originUrl,omitempty"` - // playedTime: The unix timestamp of when the track was played + // musicServiceUri: The canonical URI identifying the listening surface or music service. + MusicServiceUri *string `json:"musicServiceUri,omitempty" cborgen:"musicServiceUri,omitempty"` + // originUri: The exact URI where the listening event originated. + OriginUri *string `json:"originUri,omitempty" cborgen:"originUri,omitempty"` + // playedTime: The datetime at which playback began. PlayedTime *string `json:"playedTime,omitempty" cborgen:"playedTime,omitempty"` // recordingMbId: The MusicBrainz recording ID URI of the track, formatted as mbid: RecordingMbId *string `json:"recordingMbId,omitempty" cborgen:"recordingMbId,omitempty"` diff --git a/api/teal/feedplay.go b/api/teal/feedplay.go index 1c571e3..1a22289 100644 --- a/api/teal/feedplay.go +++ b/api/teal/feedplay.go @@ -19,11 +19,11 @@ type FeedPlay struct { Duration *int64 `json:"duration,omitempty" cborgen:"duration,omitempty"` // isrc: The ISRC code associated with the recording Isrc *string `json:"isrc,omitempty" cborgen:"isrc,omitempty"` - // musicServiceBaseDomain: The base domain of the music service. e.g. music.apple.com, tidal.com, spotify.com. Defaults to 'local' if unavailable or not provided. - MusicServiceBaseDomain *string `json:"musicServiceBaseDomain,omitempty" cborgen:"musicServiceBaseDomain,omitempty"` - // originUrl: The URL associated with this track - OriginUrl *string `json:"originUrl,omitempty" cborgen:"originUrl,omitempty"` - // playedTime: The unix timestamp of when the track was played + // musicServiceUri: The canonical URI identifying the listening surface or music service. + MusicServiceUri *string `json:"musicServiceUri,omitempty" cborgen:"musicServiceUri,omitempty"` + // originUri: The exact URI where the listening event originated. + OriginUri *string `json:"originUri,omitempty" cborgen:"originUri,omitempty"` + // playedTime: The datetime at which playback began. PlayedTime *string `json:"playedTime,omitempty" cborgen:"playedTime,omitempty"` // recordingMbId: The MusicBrainz recording ID URI of the track, formatted as mbid: RecordingMbId *string `json:"recordingMbId,omitempty" cborgen:"recordingMbId,omitempty"` diff --git a/lexicons/teal/feed/defs.json b/lexicons/teal/feed/defs.json index 2e932d6..80439f2 100644 --- a/lexicons/teal/feed/defs.json +++ b/lexicons/teal/feed/defs.json @@ -51,13 +51,15 @@ "type": "string", "description": "The ISRC code associated with the recording" }, - "originUrl": { + "originUri": { "type": "string", - "description": "The URL associated with this track" + "format": "uri", + "description": "The exact URI where the listening event originated." }, - "musicServiceBaseDomain": { + "musicServiceUri": { "type": "string", - "description": "The base domain of the music service. e.g. music.apple.com, tidal.com, spotify.com. Defaults to 'local' if not provided." + "format": "uri", + "description": "The canonical URI identifying the listening surface or music service." }, "submissionClientAgent": { "type": "string", @@ -68,7 +70,7 @@ "playedTime": { "type": "string", "format": "datetime", - "description": "The unix timestamp of when the track was played" + "description": "The datetime at which playback began." } } }, diff --git a/lexicons/teal/feed/play.json b/lexicons/teal/feed/play.json index 9c945ae..df5a526 100644 --- a/lexicons/teal/feed/play.json +++ b/lexicons/teal/feed/play.json @@ -71,13 +71,15 @@ "type": "string", "description": "The ISRC code associated with the recording" }, - "originUrl": { + "originUri": { "type": "string", - "description": "The URL associated with this track" + "format": "uri", + "description": "The exact URI where the listening event originated." }, - "musicServiceBaseDomain": { + "musicServiceUri": { "type": "string", - "description": "The base domain of the music service. e.g. music.apple.com, tidal.com, spotify.com. Defaults to 'local' if unavailable or not provided." + "format": "uri", + "description": "The canonical URI identifying the listening surface or music service." }, "submissionClientAgent": { "type": "string", @@ -88,7 +90,7 @@ "playedTime": { "type": "string", "format": "datetime", - "description": "The unix timestamp of when the track was played" + "description": "The datetime at which playback began." }, "trackDiscriminant": { "type": "string", diff --git a/models/lexicon_format.go b/models/lexicon_format.go index aad670a..d848222 100644 --- a/models/lexicon_format.go +++ b/models/lexicon_format.go @@ -33,7 +33,7 @@ func FormatMBIDURI(id *string) *string { return &formatted } -func FormatMusicServiceBaseDomain(service string) *string { +func FormatMusicServiceURI(service string) *string { trimmed := strings.TrimSpace(service) if trimmed == "" { return nil @@ -41,14 +41,13 @@ func FormatMusicServiceBaseDomain(service string) *string { normalized := strings.ToLower(trimmed) if alias, ok := serviceDomainAliases[normalized]; ok { - return &alias + normalized = alias } if strings.Contains(normalized, "://") { parsed, err := url.Parse(normalized) if err == nil && parsed.Hostname() != "" { - host := parsed.Hostname() - return &host + normalized = parsed.Hostname() } } @@ -56,5 +55,6 @@ func FormatMusicServiceBaseDomain(service string) *string { normalized = strings.SplitN(normalized, "/", 2)[0] } - return &normalized + uri := "https://" + normalized + return &uri } diff --git a/models/lexicon_format_test.go b/models/lexicon_format_test.go index 537d9b7..3b919cf 100644 --- a/models/lexicon_format_test.go +++ b/models/lexicon_format_test.go @@ -23,23 +23,23 @@ func TestFormatMBIDURI(t *testing.T) { } } -func TestFormatMusicServiceBaseDomain(t *testing.T) { +func TestFormatMusicServiceURI(t *testing.T) { tests := []struct { name string in string want *string }{ {name: "empty"}, - {name: "alias", in: "spotify", want: strPtr("spotify.com")}, - {name: "lastfm alias", in: "lastfm", want: strPtr("last.fm")}, - {name: "url", in: "https://open.spotify.com/track/test", want: strPtr("open.spotify.com")}, - {name: "domain with path", in: "music.apple.com/us/album/test", want: strPtr("music.apple.com")}, - {name: "domain", in: "ListenBrainz.org", want: strPtr("listenbrainz.org")}, + {name: "alias", in: "spotify", want: strPtr("https://spotify.com")}, + {name: "lastfm alias", in: "lastfm", want: strPtr("https://last.fm")}, + {name: "url", in: "https://open.spotify.com/track/test", want: strPtr("https://open.spotify.com")}, + {name: "domain with path", in: "music.apple.com/us/album/test", want: strPtr("https://music.apple.com")}, + {name: "domain", in: "ListenBrainz.org", want: strPtr("https://listenbrainz.org")}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got := FormatMusicServiceBaseDomain(tt.in) + got := FormatMusicServiceURI(tt.in) assertStringPtr(t, got, tt.want) }) } diff --git a/service/atproto/submission.go b/service/atproto/submission.go index 5ba3678..a0e1adf 100644 --- a/service/atproto/submission.go +++ b/service/atproto/submission.go @@ -81,12 +81,12 @@ func TrackToPlayRecord(track *models.Track) (*teal.FeedPlay, error) { isrcPtr = &track.ISRC } - var originUrlPtr *string + var originURI *string if track.URL != "" { - originUrlPtr = &track.URL + originURI = &track.URL } - servicePtr := models.FormatMusicServiceBaseDomain(track.ServiceBaseUrl) + serviceURI := models.FormatMusicServiceURI(track.ServiceBaseUrl) var releaseNamePtr *string if track.Album != "" { @@ -100,18 +100,18 @@ func TrackToPlayRecord(track *models.Track) (*teal.FeedPlay, error) { } playRecord := &teal.FeedPlay{ - LexiconTypeID: "fm.teal.feed.play", - TrackName: track.Name, - Artists: artists, - Duration: durationPtr, - PlayedTime: playedTimeStr, - RecordingMbId: models.FormatMBIDURI(track.RecordingMBID), - ReleaseMbId: models.FormatMBIDURI(track.ReleaseMBID), - ReleaseName: releaseNamePtr, - Isrc: isrcPtr, - OriginUrl: originUrlPtr, - MusicServiceBaseDomain: servicePtr, - SubmissionClientAgent: &submissionAgent, + LexiconTypeID: "fm.teal.feed.play", + TrackName: track.Name, + Artists: artists, + Duration: durationPtr, + PlayedTime: playedTimeStr, + RecordingMbId: models.FormatMBIDURI(track.RecordingMBID), + ReleaseMbId: models.FormatMBIDURI(track.ReleaseMBID), + ReleaseName: releaseNamePtr, + Isrc: isrcPtr, + OriginUri: originURI, + MusicServiceUri: serviceURI, + SubmissionClientAgent: &submissionAgent, } return playRecord, nil diff --git a/service/playingnow/playingnow.go b/service/playingnow/playingnow.go index 257473b..7c6c5a4 100644 --- a/service/playingnow/playingnow.go +++ b/service/playingnow/playingnow.go @@ -251,12 +251,12 @@ func (p *Service) trackToPlayView(track *models.Track) (*teal.FeedDefs_PlayView, isrcPtr = &track.ISRC } - var originUrlPtr *string + var originURI *string if track.URL != "" { - originUrlPtr = &track.URL + originURI = &track.URL } - servicePtr := models.FormatMusicServiceBaseDomain(track.ServiceBaseUrl) + serviceURI := models.FormatMusicServiceURI(track.ServiceBaseUrl) var releaseNamePtr *string if track.Album != "" { @@ -270,17 +270,17 @@ func (p *Service) trackToPlayView(track *models.Track) (*teal.FeedDefs_PlayView, } playView := &teal.FeedDefs_PlayView{ - TrackName: track.Name, - Artists: artists, - Duration: durationPtr, - PlayedTime: playedTimeStr, - RecordingMbId: models.FormatMBIDURI(track.RecordingMBID), - ReleaseMbId: models.FormatMBIDURI(track.ReleaseMBID), - ReleaseName: releaseNamePtr, - Isrc: isrcPtr, - OriginUrl: originUrlPtr, - MusicServiceBaseDomain: servicePtr, - SubmissionClientAgent: &submissionAgent, + TrackName: track.Name, + Artists: artists, + Duration: durationPtr, + PlayedTime: playedTimeStr, + RecordingMbId: models.FormatMBIDURI(track.RecordingMBID), + ReleaseMbId: models.FormatMBIDURI(track.ReleaseMBID), + ReleaseName: releaseNamePtr, + Isrc: isrcPtr, + OriginUri: originURI, + MusicServiceUri: serviceURI, + SubmissionClientAgent: &submissionAgent, } return playView, nil diff --git a/service/playingnow/playingnow_test.go b/service/playingnow/playingnow_test.go index d460ecd..71ec4c0 100644 --- a/service/playingnow/playingnow_test.go +++ b/service/playingnow/playingnow_test.go @@ -87,11 +87,11 @@ func TestTrackToPlayView(t *testing.T) { t.Errorf("ISRC not set correctly") } - if playView.OriginUrl == nil || *playView.OriginUrl != "https://open.spotify.com/track/test" { + if playView.OriginUri == nil || *playView.OriginUri != "https://open.spotify.com/track/test" { t.Errorf("Origin URL not set correctly") } - if playView.MusicServiceBaseDomain == nil || *playView.MusicServiceBaseDomain != "spotify.com" { + if playView.MusicServiceUri == nil || *playView.MusicServiceUri != "https://spotify.com" { t.Errorf("Music service not set correctly") } }