Hi all, I am working with MusicKit and have managed to get a user's recommendation playlists (favorites, get up, etc). Isolating just one, I am trying to access the tracks in there using .tracks but it returns nothing. Wondering if I am doing something wrong or if these don't have tracks necessarily associated with them.
Code is below
(not everything just kinda where I am accessing the playlist)
try await requestMusicAuthorization()
let request = MusicPersonalRecommendationsRequest()
let response = try await request.response()
guard let madeForYou = response.recommendations.first(where: { $0.title == "Made for You" }) else {
throw NSError(domain: "RecommendationError", code: 0, userInfo: [NSLocalizedDescriptionKey: "No 'Made for You' recommendation found."])
}
guard let firstPlaylist = madeForYou.playlists.first else {
throw NSError(domain: "PlaylistError", code: 1, userInfo: [NSLocalizedDescriptionKey: "No playlists found in 'Made for You' recommendation."])
}
print("Fetching tracks for playlist: \(firstPlaylist.name ?? "Unknown")")
let playlistRequest = MusicCatalogResourceRequest<Playlist>(matching: \.id, equalTo: firstPlaylist.id)
let playlistResponse = try await playlistRequest.response()
guard let playlist = playlistResponse.items.first else {
throw NSError(domain: "PlaylistError", code: 2, userInfo: [NSLocalizedDescriptionKey: "Couldn't fetch the playlist details."])
}
guard let tracks = playlist.tracks else {
throw NSError(domain: "PlaylistError", code: 3, userInfo: [NSLocalizedDescriptionKey: "No tracks found in the playlist."])
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi! Im attempting to make a spotify to apple playlist converter and to do so am using the Catalog search functionality of the api. My question is, is there anyway to convert these songs to apple music urls (or ids) that does not spam api calls. I know you can batch catalog searches if you have apple music song ids, but I obviously dont have that since the song was shared from spotify. Any ideas/help is appreciated!
Hey guys, I've been searching high and low for some clarity when it comes to this topic.
Essentially, what is the legality/risk of using apple music previews in my app. Does Apple license the previews meaning they are fair to use as long as I link to that URL? Do i need to license every song individually?
I can not find anything concrete out and while the apple team let my app (that currently plays preview urls) on the app store I know that doesn't necessarily legally cover me.
Any input is appreciated, i know this is a pretty niche area.
Topic:
Community
SubTopic:
Apple Developers