问题
I am currently developing a 3rd-party client for Apple Music on iOS devices, but got stuck when trying to fetch artworks for catalog playlists.
According to Apple Music API, "Get a Catalog Playlist", we may fetch a playlist by using its identifier as a path parameter, and the URL of the artwork is contained in the response : https://developer.apple.com/documentation/applemusicapi/get_a_catalog_playlist
However, the playlist identifier is nowhere to be found, does anyone know how exactly can I access "the unique identifier for the playlist"? Any help would be appreciated!
Code I have tried but did not work:
let playlistQuery: MPMediaQuery = MPMediaQuery.playlists()
let playlists = playlistQuery.collections
guard playlists != nil else { return }
for playlist in playlists! {
print(playlist.value(forProperty: MPMediaPlaylistPropertyPersistentID ))
}
The above code print out strings like: 15225742680232009793
while the correct id samples look like: pl.acc464c750b94302b8806e5fcbe56e17
回答1:
Problem solved, in case anyone comes after me wondering, you may use the "Get All Library Playlists" as a web service endpoint to fetch all library playlists (including the ones user-created and Apple shared publicly).
Check in the link: https://developer.apple.com/documentation/applemusicapi/get_all_library_playlists
The response contains pretty much all you need for a playlist.
If anyone has other solutions, you may share them down here, thank you.
来源:https://stackoverflow.com/questions/56524535/how-to-get-a-catalog-playlist-id-for-apple-music-api