Playlist's curatorName property always returns nil.

I am trying to get the name of the playlist’s curator using curatorName property of Playlist. It is of the type optional String.

I've tried many playlists, but curatorName always returns nil.

Please help. Thank you

Answered by Frameworks Engineer in 682158022

Hello @RahulRS ,

Thanks for providing more details on how you're fetching these playlists.

Here, you are loading playlists from the Get All Library Playlists endpoint from Apple Music API, and that returns a resource collection of what is defined in Apple Music API as LibraryPlaylists. That type does not support the curatorName property, as you can see in the list of attributes for LibraryPlaylists.

That is why you're getting nil from the curatorName property in MusicKit's Playlist.

So this behaves exactly as designed. If you think curatorName should be made available in Apple Music API's LibraryPlaylists, then I recommend you file an enhancement request for that in Feedback Assistant.

I hope this helps.

Best regards,

Where did you see it is optional ?

That's not what doc says here:

curatorName

string (Required) The display name of the curator.

https://developer.apple.com/documentation/applemusicapi/playlists/attributes

Hello @RahulRS ,

We need more technical information to be able to investigate this issue. Can you tell us which version of iOS you're using? And also, can you copy/paste the code you're using to fetch playlists?

We need to know exactly how you're getting these playlists.

Thanks,

@JoeKun,

I should have provided these details when asking the question. Sorry about that.

I am using iOS 15 beta 3. Here's the code I am using to fetch library playlists:

var playlists: [Playlist]
struct MyPlaylistsResponse: Decodable {
    let data: [Playlist]
}
let url = URL(string: "https://api.music.apple.com/v1/me/library/playlists")!
let dataRequest = MusicDataRequest(urlRequest: URLRequest(url: url))
do {
    let dataResponse = try await dataRequest.response()
    let decoder = JSONDecoder()
    let playlistsResponse = try decoder.decode(MyPlaylistsResponse.self, from: dataResponse.data)
    playlists = playlistsResponse.data
} catch let error {
    print("** Error **")
    print(error)
}

and then I am trying to get the curator name like this:

for playlist in playlists {
    print(playlist.curatorName)
}

playlist.curatorName returns nil for all playlists in array.

Accepted Answer

Hello @RahulRS ,

Thanks for providing more details on how you're fetching these playlists.

Here, you are loading playlists from the Get All Library Playlists endpoint from Apple Music API, and that returns a resource collection of what is defined in Apple Music API as LibraryPlaylists. That type does not support the curatorName property, as you can see in the list of attributes for LibraryPlaylists.

That is why you're getting nil from the curatorName property in MusicKit's Playlist.

So this behaves exactly as designed. If you think curatorName should be made available in Apple Music API's LibraryPlaylists, then I recommend you file an enhancement request for that in Feedback Assistant.

I hope this helps.

Best regards,

Playlist's curatorName property always returns nil.
 
 
Q