Skip to content

Commit

Permalink
fix: send track pagination using generic api request sender
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Dec 2, 2024
1 parent c3303e7 commit ece7e0d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/apis/applemusic/playlists.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package applemusic

import (
"fmt"
"net/http"
"time"

"github.com/gleich/lcp-v2/internal/apis"
"github.com/gleich/lumber/v3"
)

Expand Down Expand Up @@ -48,7 +50,12 @@ func fetchPlaylist(id string) (playlist, error) {
}
totalResponseData = append(totalResponseData, trackData.Data...)
for trackData.Next != "" {
trackData, err = sendAppleMusicAPIRequest[playlistTracksResponse](trackData.Next)
req, err := http.NewRequest("GET", trackData.Next, nil)
if err != nil {
lumber.Error(err, "failed to create pagination request")
return playlist{}, err
}
trackData, err = apis.SendRequest[playlistTracksResponse](req)
if err != nil {
lumber.Error(err, "failed to paginate through tracks for playlist with id of", id)
return playlist{}, err
Expand Down

0 comments on commit ece7e0d

Please sign in to comment.