MusicCatalogChartsRequest and kinds

Hi there!

I was experimenting with the MusicCatalogChartsRequest. I have one doubt, and I do not know if it is the intended behavior.

If I have the kinds as [.cityTop] and the types as [Song.self], why does it print the city playlists and the top played playlists?

Ideally, it should print an empty array, right? As I have only Song as a type?

var request = MusicCatalogChartsRequest(kinds: [.cityTop], types: [Song.self])
request.limit = 1
let response = try await request.response()

print(response.playlistCharts)

The output is:

[MusicCatalogChart<Playlist>(
 id: "city-top:cityCharts",
 kind: .cityTop,
 title: "City Charts",
 items: [
  Playlist(
   id: "pl.db537759ae3341eaa600bc5482209f7c",
   name: "Top 25: Mumbai",
   curatorName: "Apple Music",
   isChart: true,
   kind: "editorial",
   lastModifiedDate: "2022-06-21",
   url: "https://music.apple.com/in/playlist/top-25-mumbai/pl.db537759ae3341eaa600bc5482209f7c"
  )
 ],
 hasNextBatch: true
), MusicCatalogChart<Playlist>(
 id: "most-played:playlists",
 kind: .mostPlayed,
 title: "Top Playlists",
 items: [
  Playlist(
   id: "pl.f4d106fed2bd41149aaacabb233eb5eb",
   name: "Today’s Hits",
   curatorName: "Apple Music Hits",
   isChart: false,
   kind: "editorial",
   lastModifiedDate: "2022-06-21",
   shortDescription: "Drake gets loose with “Sticky”.",
   standardDescription: "Among the many surprises of Drake’s <i>Honestly, Nevermind</i>—not the least of which is the album’s very existence—is that it isn’t really a hip-hop album at all; he’s mainly singing. But “Sticky” is one of the few tracks where the project’s commitment to exploring dance music—courtesy here of production work from Australian artist RY X and Gordo (aka DJ Carnage)—meets actual rapping. Add Today’s Hits to your library to stay up on the biggest songs in pop, hip-hop, R&B and more.",
   url: "https://music.apple.com/in/playlist/todays-hits/pl.f4d106fed2bd41149aaacabb233eb5eb"
  )
 ],
 hasNextBatch: true
)]

Thank you!

Answered by Frameworks Engineer in 718837022

Oh I see. Fair enough. I just forgot about that small implementation detail.

Yes, I suppose our current client-side implementation does diverge from Apple Music API in that regard.

I think you should file a ticket on Feedback Assistant about this. We can probably improve this area of the MusicCatalogChartsRequest.

Thank you very much in advance.

Best regards,

Hello @snuff4,

This behavior simply matches what Apple Music API returns from the Get Catalog Charts endpoint.

I suppose we could filter out these playlist results in this case, but I didn't see much of a point in doing that. If the data was loaded from the network, I think we might as well pass it to the client.

Given how the corresponding server endpoint works, I believe the current behavior of MusicKit's MusicCatalogChartsRequest makes sense.

I hope this helps.

Best regards,

My confusion stemmed from the fact that the most played playlists are added in the results even though the type is only Song.self.

If I hit the endpoint:

https://api.music.apple.com/v1/catalog/us/charts?types=songs&chart=most-played&with=cityCharts

The corresponding result only has the most played songs and city top charts:

"results": {
            "order": [
                "most-played:songs",
                "city-top:cityCharts"
            ]
        }

But MusicCatalogChartsRequest also adds the most played playlists

Accepted Answer

Oh I see. Fair enough. I just forgot about that small implementation detail.

Yes, I suppose our current client-side implementation does diverge from Apple Music API in that regard.

I think you should file a ticket on Feedback Assistant about this. We can probably improve this area of the MusicCatalogChartsRequest.

Thank you very much in advance.

Best regards,

MusicCatalogChartsRequest and kinds
 
 
Q