Spotify vs Last FM, display last played track - spotify

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.

Related

Play a defined song on Spotify with Google Actions

I am a new user to Google Home SDK. I am developing a simple app where it takes what I said and takes some defined actions.
What I wanted to implement is, when I say "play the special song for someones-name", Google assistant will respond "here you go" followed by playing the defined song from Spotify. I can hard code the artist's name, album into the app. And I have already linked Spotify to my Google Home Assistant.
I have a couple specific questions after getting lost in reading the topics on Create conversational experiences from scratch by Google:
(1) Suppose I just need to hard code the song and album name and let Spotify play it, is there any code snippet for that purpose? I'm new to Node.js, so may be it's easier than I thought.
(2) I am developing the app using my dev account on GCP, say Account-A, it is different from the Google Account I signed in on my home device, say Account-B. How do I deploy and test the app on the home device?
Much appreciated for your help and advise.
There's no way to start up a standard Spotify session through a conversational action. If you have the media file, you could have your conversational action play a MediaResponse.
Alternatively, you may instead want to create a routine that accepts a given query and completes an action. That will allow you to start a media stream for whatever you want.

Is it possible to control the spotify desktop client from a browser with custom controls?

I am a developer for playmoss where users can create playlists with different music services.
We are planning on adding Spotify support to our playlists in a way similar to what bop.fm does.
Context
Taking for example this playlist (in which all songs are available on spotify, at least in Spain)…
https://bop.fm/p/o12l
…if we have the spotify client installed in our computer (tested with a Mac)
As soon as the playlist starts playing we can click the spotify icon on the top right [picture]and we will be playing the songs through spotify.
Using the bop.fm control interface we can pause, play, skip next, even skip to a point in the track with progress bar.
This is similar but even more powerful than the official spotify play button, see an example here:
http://jsfiddle.net/insonorizate/a5jf39yn/
With the play button there is previous, play, pause, next functionality but not seek.
Of course it can not be customized in any way nor called from javascript.
(in bop.fm is possible to open a debuger console and call
Bop.Player.pause()
or
Bop.Player.play()
to pause or play the track beeing played in bop.fm via spotify)
Fiddling a little with the bop.fm page there are some interesting things. Ther is an iframe in the main page poiting to:
https://embed.spotify.com/remote-control-bridge/
Viewing this iframe source we find something like this:
// Expose the OAuth Token to the Javascript
var tokenData = 'NAowChgKB1Nwb3RpZnkSABoGmAEByAEBJReQCFQSFG2Ynvz1oBKgxv2mE1XXz_1Au-cg';
// Pass the remote control to the bridge
var remoteControlBridge = new Spotify.RemoteControlBridge();
remoteControlBridge.init(tokenData);
There's no documentation for Spotify.RemoteControlBridge (0 results for "Spotify.RemoteControlBridge" on google) and there isn't any thing in the documentation of the different apis even close to controling the spotify player in a way similar to this.
Question
How can I control the spotify desktop app from a browser?
Does bop.fm have any special arrangment with spotify and they are using some "secret api"?
Are they exploiting some functionality that I fail to find?
Is it possible to replicate it?
Is it in accordance with the Spotify terms?
Thanks!
You can't control the Spotify Client or Listen to Events the Spotify Web Helper is emitting. Imagine everybody could: every website could potentially play a song without your permission or even know instantly what you are listening to. To prevent this Spotify only allows approved partners to use this feature.
As you figured out the remote-control-bridge provides this functionality. It can communicate with the Spotify Web Helper running on your system, which is secured by an OAuth and a CSRF Token. In the remote-control-bridge you even can see the allowed partners:
Spotify (who knew)
Yahoo
last.fm
coachella.com
bop.fm
sandpit.us
echonest
musixmatch
You can contact them and ask for a partnership. I'm sure they won't bite.
This is actually a little bit documentated on the website of Spotify in the developers section.
I think bop.fm does use their custom Spotify Play Button widget. That makes use of the iframe that you mentioned.
Here you can find the documentation about this functionality of Spotify. You can then modify it to your own needs using Javascript etc.

How to grab user track info through spotify api

I recently just got through the beginning tutorial for creating a web app with the spotify api. https://developer.spotify.com/web-api/tutorial/. The tutorial was great for showing how to authenticate a user with oauth and log in a user.
The problem I am having is with the endpoint. I can't seem to figure out how to change the endpoint so that instead of displaying a users profile, I can see a list of a users track, better yet starred or top 10 tracks.
for a 10,000 view perspective of what I want to build is a app that would allow users to easily log in through their spotify account, take their stared or top tracks and push them to a radio that I am building with an raspberry pi.
I am new to working with the spotify api and working with api's in general so whatever advice would be awesome.
At the moment, there is no way to get the "starred"-playlist. (At least it's not documented)
I don't know what you mean with "Top 10 User tracks", since this doesn't exist as far as I know
To get a list of the account's current playlists, change the URL to:
https://api.spotify.com/v1/users/{user_id}/playlists
With this URL, you will get a list of simple-playlist-objects wrapped inside a paging-object. Now you can select one of the playlists (or loop through them) and fetch its track this way
NOTE:
If you also want to fetch private playlists, make sure you use the scope playlist_read_private

How to lookup Spotify User metadata (playlists, currently playing, etc)

I only see Artist, Album, and Tracks lookups in the docs. I want to display what I'm currently listening to. Is there a way to do this using the API?
https://developer.spotify.com/technologies/web-api/lookup/
Spotify does not provide this at this time. You can either get it by turning on last.fm scrobbling or accessing facebook music data.
As Thomas said Spotify does not provide such a feature 'directly'.
But there are some ways to get it work.
You have to me some more sprcific what you want to do. Web/Desktop/App
I wrote a tiny console app using an external dll
"File/Link removed" - send pm for further information!
If this is what you need just message me. It's a rly tiny application just for test purposes! Because I currently develop a overlay.

Prevent song playing on URI link click

I'm working on a Spotify app where I'd like for users to be able to click on track names and be linked to the track page, just like in other Spotify apps. I'd like to prevent the song from beginning playback, though.
SoundDrop seems to do this. You can click on a track name and the song doesn't interrupt playback by SoundDrop.
I'm not sure how to implement this alternative behavior. Any ideas?
The Apps API uses standard JavaScript stuff, so if you attach a handler to the track link and use e.preventDefault(), that should prevent Spotify playing the track and you can then do your own custom handling.
More discussion on e.preventDefault() is here: event.preventDefault() vs. return false

Resources