Getting Spotify-generated artist playlists using Web API - spotify

When Siri is asked "play music by ARTIST_NAME on Spotify" she starts playing music from a playlist that is generated by Spotify, with no displayed name, and the description "ARTIST_NAME songs picked just for you". I cannot find a way to find this playlist. Its name, according to the https://api.spotify.com/v1/me/player endpoint, is ARTIST_NAME, and its owner is Spotify. How can I find this playlist for a given artist using the Web API?
Ultimately, I am trying to work around the fact that if there is no available device (i.e. Spotify is idle or closed) an artist cannot be played by setting a context-uri in the https://api.spotify.com/v1/me/player/play endpoint. To work around this issue in the case of playing a playlist that the user of my program searches for, I have simply opened the URL of the first track in the album or playlist. This doesn't work in the case of artists, since the list of top tracks by an artists gives the tracks' URLs in the context of the respective tracks's album.
If there is no way to access this Siri exclusive playlist, I would appreciate feedback suggesting alternate routes. It is not sufficient to simply create a playlist, since they would be static and have to be recreated for each request.
Thank you.

Related

Accesing my account on spotify and playing liked songs python

I want to create a program that, if called, will access my liked songs playlist on Spotify and play either a random song or a song that has been called. I know that I should use the Spotify library, however, I don't really know how to achieve my goal, as most tutorials are about creating a new playlist or something of that nature, not accessing an already present playlist like liked songs.
Any advice will be appreciated:)
You could use the pyspotify library. This part of the documentation goes in detail on how to play music and mess with playlists.

Is it possible to generate a playlist from two users liked music or playlists, through Spotify or Apple Music?

I am trying to generate a playlist from two users different playlists. I know you can get a public playlist from a Spotify users id, hopefully their most played,but i am not sure if you can combine it with another user's playlist?
Sure. First read both of the users Spotify playlists. You'll have to use the iTunes Search API to find the respective track on iTunes and it's product ID. You can then use the music API's added in 9.3+ to make a playlist and add the product ID's for the songs in the two playlists.

Create app-bound playlist on Spotify

Is it possible to create an app-bound playlist?
It's possible to create a playlist for a user, but how will I know which one that is when they move away from my app?
Ideally, I would only need to be able to create/edit 1 playlist.
Edit: Have found this http://developer.spotify.com/technologies/apps/guidelines/integration/#appsthatcreateplaylisturi:s
But if anyone has great ideas, I'm still open!
As you've found out yourself, you can't create a playlist in a user's library that's somehow linked to your application using the Spotify Apps API.
I thought it'd be a good idea to also quote the relevant part of the Integration Guidelines that you've linked to:
If you want to generate and save the user’s personal playlists in the
app, you should not keep playlist information only saved within the
app. Playlist information should instead be handled by utilizing user
playlists, so that the user can access playlists as usual. They
shouldn’t have to go to the app to access a certain playlist that they
have created.
Suggestion:
I think there's several ways to do what you want to do though.
One way could be to let a user create a new playlist using your application and save it to the user's library, and at the same time save the playlist URI to your own back end. As you've noted, playlist URIs are obfuscated (e.g. they look like spotify:user:#:playlist:783BHaT7Xb8K5VyYstxsj3 instead of spotify:user:thelinmichael:playlist:783BHaT7Xb8K5VyYstxsj3, the username is replaced by # for the currently logged in user, and #xxx.. for other users). You could still save the last part of the URI, which I believe is unique for every playlist. Using a hashmap to map that part of the playlist URI to properties you want to keep track of would let you do quick lookups of a user's playlists to see if they are associated to your app. You could iterate though the user's library to gather all obfuscated URIs, and send them to your backend in a single HTTP request. The response from your server could be the index of the library playlists that matched the playlist on your backend, along with the properties you've mapped to it. Again, this was just a suggestion and possibly not the best way forward but I hope it gave you some ideas. :-)

spotify apps javascript crossfading

How to achieve crossfading on a Spotify javascript based app?
I'm creating a temp playlist and adding songs to it on the fly, the added song plays but doesn't crossfade.
EDIT: I guess the real question is how to cause Spotify to do a refresh of the play queue. the added songs get added to the visible play queue only on the track change, which makes it not crossfade.
There is currently no programmatic access to crossfading in a spotify app (https://developer.spotify.com/technologies/apps/docs/beta/f19ff300f8.html)
However, if the user has crossfading enabled (Settings->Playback->Crossfade tracks) and the model.Player is playing from a context with multiple tracks (like a Playlist or Album) then crossfading should kick in.
The caveat here is that you have to have the next song in the playlist added early-on enough so that the client has time to recognize the change in the playlist. One way to verify if you're adding this in time is to ensure the 'Play Queue' shows that it will play the next song in your playlist.

Spotify vs Last FM, display last played track

I was looking for a way to display my last played Spotify track on my website. I succeeded using the Last.FM API. Spotify doesn't have an open API and the music part of Facebook seems to be locked down too. So I now scrobble everything to last.fm and use their API to get the last played song. This works fine, but I thought it would be fun to display a "play now" button to play the track on spotify.
To do that, I need the Spotify ID for the particular song, which the last.fm api doesn't seem to return.
So... two questions:
1) is there a way to get the same info from Spotify itself?
2) if not, is there a good way to get the matching spotify song using the Last.FM details?
1) No. Spotify doesn't have a play history API. However, you can use Facebook's listens endpoint if the user is publishing listens to Facebook.
2) Not directly, as far as I'm aware. However, a quick Google turns up this project. Failing that, you can use the Spotify Web Search API to search for a track matching the metadata. The Advanced Search Syntax may come in handy here.

Resources