AppleMusicAPI.NET icon indicating copy to clipboard operation
AppleMusicAPI.NET copied to clipboard

Can't Pull Playlist Data

Open ijabit opened this issue 7 years ago • 5 comments

Great library!

When I call the method GetCatalogPlaylist it generates a response from the following URL: https://api.music.apple.com/v1/catalog/us/playlists/pl.1c35ac10cfe848aaa19f68ebe62ea46e

The JSON serializer can't deserialize the result and throws the following exception: "Could not create an instance of type AppleMusicAPI.NET.Models.Core.ResourceRoot. Type is an interface or abstract class and cannot be instantiated. Path 'data[0].relationships.tracks.data[0].id', line 1, position 1417."

I noticed that the properties on the relationship track object have a Meta property but no Attributes property to represent the attributes in the JSON data returned. Maybe that's part of the problem? I don't really know how to troubleshoot this issue.

Can you point me in the right direction at least?

ijabit avatar Oct 12 '18 22:10 ijabit

Okay I did some digging and found a workaround: https://github.com/MattPress/AppleMusicAPI.NET/blob/master/src/AppleMusicAPI.NET.Models/Relationships/TrackRelationship.cs

The Relationship class it is inheriting from doesn't have the Playlist generic type parameter. When I make that class inherit from Relationship<Playlist> it works! But I don't know if the intent was to have this class used from multiple relationships other than Playlist so I'll leave it up to the author to decide what to do about this.

ijabit avatar Oct 15 '18 14:10 ijabit

Hi, @ijabit apologies for the very late response, not ideal but been really busy!

This issue has been addressed but needs to be released. There are a few issues with the json serialising which need ironed out. So far the releases have essentially been pre-release but my eagerness to get everything up and running has resulted in incredibly poor quality management. I hope to have these additional issues fixed and proper tests in place to ensure everything is working as it should prior to the next release.

If you notice any other issues please let me know regardless of if you are using the nuget package or not, really appreciate the input.

Thanks, Matt

MattPress avatar Nov 05 '18 16:11 MattPress

Thanks for the response. I have a fork of the code anyways with the workaround I mentioned above in place. I also added the ability to initialize DI with a pre-generated key, instead of requiring the certificate and generating it on the fly. I think it's a nice enhancement if you're interested.

ijabit avatar Nov 05 '18 16:11 ijabit

Sure, just open a PR!

MattPress avatar Nov 05 '18 16:11 MattPress

Issue mentioned fixed in ongoing PR https://github.com/MattPress/AppleMusicAPI.NET/pull/7

MattPress avatar Nov 08 '18 12:11 MattPress