Post

Replies

Boosts

Views

Activity

editorialNotes always nil when fetching the Artist model in MusicKit API
For some reason no matter witch approach to take to get editorialNotes from Artist struct it always returns nil. The first approach is to use MusicCatalogResourceRequest - from MusicKit2 framework like this let album = try await album?.with(.artistURL) guard let url = album?.artistURL else { return } let id = MusicItemID(url.lastPathComponent) let request = MusicCatalogResourceRequest<Artist>(matching: \.id, equalTo: id) let requestScopes: [PartialMusicAsyncProperty<Artist>] = [.latestRelease, .featuredAlbums, .fullAlbums, .liveAlbums, .singles, .compilationAlbums, .similarArtists] let response = try await request.response() guard let artistResponse = response.items.first else { return } let detailedArtist = try await artistResponse.with(requestScopes) self.artist = detailedArtist Or to use MusicKit1 endpoint like this. GET https://api.music.apple.com/v1/catalog/{storefront}/artists/{id} let url1 = URL(string: "https://api.music.apple.com/v1/catalog/us/artists/\(url.lastPathComponent)")! let urlRequest = URLRequest(url: url1) let artistRequest = MusicDataRequest(urlRequest: urlRequest) let arstistResponse = try await artistRequest.response() let decoder = JSONDecoder() let receivedArstist = try decoder.decode(MusicItemCollection<Album>.self, from: arstistResponse.data) if let json = try JSONSerialization.jsonObject(with: arstistResponse.data, options: []) as? [String: Any] { print(json) } For test purposes I try to put in in JSON to print out and see if editorialNotes have some value. Maybe this is a bug, please let me know how to get editorialNotes
1
0
632
Dec ’22
Why © Copyright Info of the Album is always nil?
When fetching user's Albums each album didn't contain Copyright string 🤔 For sure I doing something wrong. Task {      do {       let url = URL(string: "https://api.music.apple.com/v1/me/library/albums")!         let urlRequest = URLRequest(url: url)         let albumsRequest = MusicDataRequest(urlRequest: urlRequest)         let albumsResponse = try await albumsRequest.response()        let decoder = JSONDecoder()        let usersAlbums = try decoder.decode(MusicItemCollection<Album>.self, from: albumsResponse.data)        print("🎶👀 Here's a user's Albums - \(usersAlbums)")        albums.append(contentsOf: usersAlbums)        let copyrightInfo = usersAlbums.first?.copyright       print("© Copyright Albums string - \(String(describing: copyrightInfo))")     } catch let error {       print("Oops, error when fetching albums \(error.localizedDescription)")      } }
1
0
457
Aug ’22
What's the difference between different String format of MusicItemID?
What's the difference between MusicItemID("1603171516") and MusicItemID("i.KoJeg8VCZLNZZq")? Because when fetching [Track] of the Album when to chose let id = MusicItemID("i.KoJeg8VCZLNZZq") var request = MusicCatalogResourceRequest<Album>(matching: \.id, equalTo: id) request.properties = [.tracks] let response = try await request.response() guard let tracks = response.items.first?.tracks else { return } albumTracks = tracks It returns error ⬇️
1
0
581
Aug ’22
How to play selected Track from Album with ApplicationMusicPlayer?
Hi 👋 I load a bunch of user's albums and when I select Album I load all related tracks there's a player to play all album and below list of all tracks that album contains. To play the whole album when play button pressed var selectedAlbum: Album player.queue = [selectedAlbum] try await player.play() and then when I'd like to play specific track from the album in the List cell var track: MusicItemCollection<Track>.Element player.queue.currentEntry = .init(track) try await player.play() and it's not working. Plus when trying to get selectedAlbum.copyright and selectedAlbum.editorialNotes?.standard always return empty String Please let me know what's the issue with that and looking forward for helpful responses 🙏
1
1
674
Aug ’22