diff --git a/internal/apis/applemusic/applemusic.go b/internal/apis/applemusic/applemusic.go index c4cafcd..e3d57d7 100644 --- a/internal/apis/applemusic/applemusic.go +++ b/internal/apis/applemusic/applemusic.go @@ -81,9 +81,20 @@ func serveHTTP(c *cache.Cache[cacheData]) http.HandlerFunc { RecentlyPlayed []song `json:"recently_played"` }{} for _, p := range c.Data.Playlists { + firstFourTracks := []song{} + for _, track := range p.Tracks { + if len(firstFourTracks) < 4 { + firstFourTracks = append(firstFourTracks, track) + } + } data.PlaylistSummaries = append( data.PlaylistSummaries, - playlistSummary{Name: p.Name, ID: p.ID, TrackCount: len(p.Tracks)}, + playlistSummary{ + Name: p.Name, + ID: p.ID, + TrackCount: len(p.Tracks), + FirstFourTracks: firstFourTracks, + }, ) } diff --git a/internal/apis/applemusic/playlists.go b/internal/apis/applemusic/playlists.go index fd9c76c..8d34e6d 100644 --- a/internal/apis/applemusic/playlists.go +++ b/internal/apis/applemusic/playlists.go @@ -14,9 +14,10 @@ import ( ) type playlistSummary struct { - Name string `json:"name"` - TrackCount int `json:"track_count"` - ID string `json:"id"` + Name string `json:"name"` + TrackCount int `json:"track_count"` + FirstFourTracks []song `json:"first_four_tracks"` + ID string `json:"id"` } type playlist struct {