Apple MusicKit - Playlist creation and editing via the Apple Music API - apple-music

I have recently been using the new Apple MusicKit functionality.
I've got a Developer Token and Music-User-Token and I can run the test code provided by Apple.
I want to try and do a few more things but the documentation doesn't seem to cover it.
From what I can tell (at the moment) the User Token is only used to edit things like ratings of albums, songs etc
Source: https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/AppleMusicWebServicesReference/RateaAlbum.html#//apple_ref/doc/uid/TP40017625-CH78-SW1
Problem 1:
What I'd love to do is create a playlist (via this API rather than the native Objective-C/Swift) code.
Using the native code, the playlist ID is a GUID but this ID doesn't seem to be relevant to the Apple APIs ID for a playlist (formatted pl.u-[uniquereference])
Problem 2:
I'd also like to retrieve a list of my playlists.
Has anyone done this? Is it even possible?

You can download the Apple Music Sample Code here, and take a look function createPlaylistIfNeeded() in MediaLibraryManager.swift. It does create a playlist.
Base on my understanding you can create and retrieve the playlist by using
MPMediaLibrary.getPlaylist(with:creationMetadata:completionHandler:)
However, if you go to check this function's definition on Apple Developer Document
getPlaylist(with:creationMetadata:completionHandler:)
Retrieves an app maintained existing playlist or creates a new
playlist when no playlist exists.
So, I think you can not retrieve users' playlist unless it is created in your app.
Btw, Would you mind to share how you done with the JWT? I checked the website that the Apple provided JWT Website. But the swift library JWT it recommended on the site, has not yet supported ES256. So I had to use a python library to generate one and hardcode in the code for testing.
Please let me know if you have solved it. Thanks

Related

Get Apple Music playlist share URL programmatically by Swift

When sharing playlist in Apple Music app via Email, you can get a URL like this
https://itunes.apple.com/jp/playlist/if-you-like...may-j./idpl.4299b4c5a42048bd850eca538e68ace2?l=en
You will also have an URL when sharing local created playlist.
I would like to know if it is possible to get the URL programmatically on iOS using Swift.
[Effort studied but failed to solve]
Related discussion using link maker does not solve the problem
Apple Music URL Scheme
Query the playlist using: MPMediaQuery.playlists() and enumerated the returned playlist but cannot find any property showing the URL
I'm pretty sure this is not possible. I believe the playlist does not have the idpl value until the user manually presses the share button in iTunes. And, there's nothing in the API to create one.
I set up a proxy and had a look at the requests iTunes makes.
I created a playlist in iTunes and added songs to the playlist. Every song I added made several requests to various endpoints under:
https://ld-6.itunes.apple.com/WebObjects/MZDaap.woa/daap/update No idpl value in any of the responses.
Then I manually hit the share button. A request is made to
https://client-api.itunes.apple.com/WebObjects/MZStorePlatform.woa/wa/lookup with the idpl in the URL.
Now when you add more songs to the playlist, the responses contain the idpl.
From that it seems that the idpl is created on the device when the user touches share.
Probably best to file a radar for Apple to add a share URL property to MPMediaPlaylist.
EDIT: I filed a radar

Generate song suggestions (auto-complete)

I'm developing an app and I want a user to be able to start typing a song name/artist/whatever and then have a list/drop-down show suggestions on the fly depending on what the user typed (preferably as the user is typing).
I was thinking I would need to use some sort of API which queried the iTunes database for songs available for purchase (or any other large database with song information), but I'm open to using any other source.
Does anybody know of an API I can look into or a framework I can use. I don't need a solution in code or anything, I'm simply asking for a nod in the right direction.
Let me know if you need anymore information. Thanks.
Apple exposes a search API for the iTunes Store. That should help you. https://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
Here's a writeup by Apple describing the API: https://www.apple.com/itunes/affiliates/resources/blog/introduction---search-api.html
From there, you just have to hit the endpoint with the appropriate parameters and then display the results. The endpoint is:
https://itunes.apple.com/search?parameterkeyvalue

Facebook custom photo and video sharing action in iOS

I have video and photo sharing working fine in an iOS app using UIActivityViewController.
Now I want to upgrade it so that the app posts a custom OpenGraph story to the timeline. Something like "User posted Video from MySuperApp".
I've got the all the iOS side written, and I've got a Facebook app created and configured in the project, login, etc.
I'm a bit frustrated by the rest of the documentation, though:
The submission guidelines speak about a "user generated photos" permission that doesn't seem to be available anywhere in the app settings, or anywhere else in the documentation. Is that still required? Is there a similar permission for videos?
It says "Photos must be original and can only be those taken with a camera by the person who is publishing them". The app allows adding annotations/drawings on top of a photo. Does that still count as "original"? And I guess the normal image controls allow selecting images from an album, so I have no way to enforce this, do I? (Other than writing a completely custom camera control, I guess...)
The API allows to "stage" a photo for a story. Is it possible to stage a video, or do I need to upload it externally? Can I refer to a video in a user's album in a story?
Is it possible to use FBDialogs to post a story about a video, or do I need to write my own?
Update:
Current status: I wrote my own UIActivity to share on Facebook and my own activity view controller.
Making a custom story about a photo is straightforward, and covered by documentation and examples, but to summarize:
stage photo, returns url
create object, returns id
create action (returns id)
Make sure you set "explicitly_shared" to true, so the action appears in the timeline. It is a good idea to follow their recommendations for error handling as well, otherwise it is a pain to debug.
I am not further with videos, though. Uploading a video is easy ([FBRequest requestForUploadVideo]), but that returns an id. So far I have not been able to use this id in either an object or an action. Querying the graph API for that id doesn't return any information. The video appears on the timeline by itself as well.
I'm tempted to just ditch the custom story about the video.
Update:
Okay, based on the feedback here and on the Facebook group I have to assume that it is not possible to upload and share a video as part of a story. I'm going to strip the feature down to just upload the video to the album.

Bootstrapping under Spotify iOS SDK -- basic questions

Firstly, nice job to the Spotify iOS SDK team -- it's come a long way and it's not easy to make an async world for the sync-minded masses! :)
We have a basic query usage question that's probably answered elsewhere, but it'd be helpful to have a dev be clear on the issue (plus, there may be some new query paradigms in the new iOS SDK that could be used). Basically, our app embeds the Spotify iOS SDK, offering the ability for the user to choose high-level audio sources: "Stations" and the entries under "Your Music" ("Playlists", "Songs", "Albums", and "Artists").
So, it'd be infinitely helpful if a dev could outline which queries would be made from the iOS SDK level (and which subsequent queries would be made for the items above). If it turns out that doing initial/root-level queries is best done via the web API, could a dev please outline the official/approved method for forming a URL query?
Also, is there's a whitepaper or formal Spotify doc that formalizes Spotify URIs?
Thanks!
Drew
SoundSpectrum
In the iOS SDK, everything you need is in the SPTRequest object.
playlistsForUserInSession:callback: gives you playlists.
savedTracksForUserInSession:callback: gives you the user's saved songs.
To get the user's "Albums" and "Artists" lists, you derive this yourself from the list of saved songs - there's no API to fetch them separately.
Radio stations aren't available in our SDKs.

linking to content available on itunes, amazon.com, google play and others

Okay so I'm building a web app that aggregates entertainment (TV shows, movies, other videos, podcast's ) and it's basically all sorted into genre's recent release etc. now I would like to link to legal places on the internet that you can buy this content ie. apple itunes store, amazon.com, google play and maybe some other's. Now for the itune's store i found this handy called link maker. Now my Problem is that if I have a couple of thousand title's I have to enter each one and then again for each country to get each link... Okay I can write a script php curl or python's scrapy but is there anything similar tool for amazon? Is there a better tool then the one I have altogether for apple? I figured I can't be the first person who's run into this problem and just looking for any help, yes/no's that anyone else has found useful as my last 4 hours of googling has returned fairly little minus the link maker tool. Ideally an api but i'm now doubting those exist
iTunes offers an API for what you are attempting to do - see the documentation here:
http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html

Resources