How to understand a playlist is an editable one on MusicKit? (iOS 16)

We can get the playlists of the user by the following code block:

 var request = MusicLibraryRequest<Playlist>()

 request.sort(by: \.lastPlayedDate, ascending: false)

 let response = try await request.response()


Also, we can add a track to the playlist with the following code block:

TASK {
     do {
         try await MusicLibrary.shared.add(track, to: playlist)
      } catch (let error) {
         print(error)
     }
}


However not all playlists are editable. For instance if the playlist created by Apple or another Apple Music user, we receive an error while adding track to the playlist because we don't have a permission to do it.


How can I only retrieve playlists that are editable? Or in other words how can I retrieve playlists that are only created by the user?

The error that I am receiving is:

Domain=MPErrorDomain Code=5 "The requested action is not supported" UserInfo={NSLocalizedDescription=The requested action is not supported}

The Error that I am receiving is:

Error Domain=MPErrorDomain Code=5 "The requested action is not supported" UserInfo={NSLocalizedDescription=The requested action is not supported}

I receive the following error:

Error Domain=MPErrorDomain Code=5 "The requested action is not supported" UserInfo={NSLocalizedDescription=The requested action is not supported}

I'd love to know the answer to this one too - such a basic requirement. I raised feedback on it months ago (FB11706965).

Also you'd think that if you tried to edit a playlist that you weren't allowed to edit at least it would throw a specific member of MusicLibrary.Error which indicated what happened. But no - you get a completely generic error. The only way you can tell what happened (as far as I can see on 16.1) is by looking for a specific string in the error text (reported as FB11740727).

Actually today I tried to remove a track from the playlist, as far as I know you can only do it with (MusicLibrary.shared.edit) but It only works if the playlist is created by your app. If I try to delete a playlist that I created on Music or any other app, it gives an error with the similar description that I just mentioned.

How to understand a playlist is an editable one on MusicKit? (iOS 16)
 
 
Q