How to get a Catalog Playlist id for Apple Music A

2019-09-19 14:27发布

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条回答
相关推荐>>
2楼-- · 2019-09-19 14:59

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.

查看更多
登录 后发表回答