Hi there,
tl;dr: How can I get the id of a curator and then with that get a listing of their playlists?
I asked about curators a while back, here in this forum, but I can’t find that post, so I’m writing a new one, esp. now new curator features have been added to MusicKit as of WWDC22.
Let's say that userB wants to access one of userA's playlists.
Since userB has no way of accessing userA’s library, userA’s playlist needs to be accessible as a catalog resource. This is accomplished by userA manually performing an action in the Music App on macOS or iOS (I wish this could be done programmatically, but no, and that’s off topic).
At present, the only way that I know of to determine if a playlist available as a catalog resource is by checking for the hasCatalog
property under attributes
and/or the globalId
property under attributes.playParams.
@JoeKun once told me that globalId
should be considered opaque and should not be relied upon.
That said, adding "include=catalog"
to the request properties of a MusicDataRequest
that fetches playlists from userA's Library, like the below will give me access to catalog ID.
var playlistRequestURLComponents = URLComponents()
playlistRequestURLComponents.scheme = "https"
playlistRequestURLComponents.host = "api.music.apple.com"
playlistRequestURLComponents.path = "/v1/me/library/playlists"
playlistRequestURLComponents.queryItems = [
URLQueryItem(name:"limit", value: "100"),
URLQueryItem(name:"include", value: "catalog")
]
Note that this can only be performed by userA.
And here comes the curator question:
If userB wants to get a list of all userA’s catalog playlists (or a specific one) how can that be done?
It seems I need to know userA’s curator ID and do some sort of request on that, or I could perhaps get the curator info by performing a MusicCatalogResourceRequest<Playlist>
request, adding [.tracks, .moreByCurator]
to the request.
On the former, I got no idea how to find userA’s curator ID, even if I’m coding with a scope that has Library access for userA. The best I can seem to do is get a curatorName
when adding "include-catalog" (as above) to a MusicDataRequest
that gets a user's library playlists.
On the latter, getting the catalog ID of a playlist requires userA to perform a MusicDataRequest against their library and passing that catalogID to userB so that userB can then access the tracks. This is what my app does now.
Ideally though, I'd like to somehow have userB get userA's curator ID and then have userB get userA's catalog playlists without having userA having to do the above.
Any thoughts on how to do this would be most appreciated.