rryam / MusadoraKit

The ultimate companion to MusicKit.
http://exploringmusickit.com
MIT License
345 stars 22 forks source link

How does MusicKit love/unlove a song? #6

Closed Kejiasir closed 2 years ago

Kejiasir commented 2 years ago

Hi, how does MusicKit love/unlove a song? Do you know of any related APIs?

20220630191558

rudrankriyam commented 2 years ago

Heya! MusicKit does not have a rating API as of yet.

However, you can use MusadoraKit for this purpose. For example, to add a Love rating for a particular song, you can do so by:

let id: MusicItemID = "1628890886"
let request = MusicCatalogRatingAddRequest<Song>(matching: \.id, equalTo: id, rating: .loved)
let response = try await request.response()

print(response.items)

If it is a success, you will get the rating that contains the identifier of the music item, and the rating.

Let me know if you use it!

Kejiasir commented 2 years ago

wow, awesome, this helped me, thank you.