The new Spotify Web API allows the developer to create and add tracks to a playlist on behalf of a listener. This is a pretty powerful feature, opening the door for a whole range of apps. For instance, this weekend, I added the ability to save a Roadtrip Mixtape playlist, so you can now actually take your mixtapes on the road. The code is on github if you are interested in seeing how it is done.
#1 by Kelly Maurice on June 23, 2014 - 12:48 pm
Hi Paul,
This is one of your best if not your best demos …
It’s kind of a dumb question but I’m new to all of these APIs and have become lost.
How would one for instance restrict the genre of the whole app (like to one or two genres, like reggae and dub) [i see that you plan options for this in a future version[
I think it’s in this line of code but I can’t seem to follow where the the .JSON call ends up – is the call with ‘artists’ an echonest call?
function fetchCityArtistsForPlaylist(points, ids) { ids = filterCityIds(ids); $.getJSON(‘artists’, { id:ids.join(‘_’), count: maxArtistsPerCity}, function(data) { processCityData(data); assignArtistsToWaypoints(points, data); showTripInfo(points); }); }
My background is C and C++ and web apps are still very mysterious to me. I want to use your excellent blog and code samples to learn the stuff but even baby steps are hard at this point. If I can get one thing working properly I should be able to make progress.
thanks!! kelly
#2 by Paul on June 23, 2014 - 2:40 pm
Hi Kelly – you will have a hard time incorporating a genre filter into the current app, there are no genres attached to the artists and looking them up on the client would result in too many calls (i.e. one genre lookup per artist for lengthy roadtrip could result in 100s of API calls). The genre filtering really needs to be done on the server side. — Paul
#3 by Kelly Maurice on June 23, 2014 - 2:47 pm
Wow, I had no idea it would be that performance intensive but on a practical matter just trying to understand the code, what does ‘artists’ turn into on the getJSON call, as I couldn’t find it in the code base; it becomes a URL and request it seems but maybe that’s private data of yours that is hidden? Thanks and looking forward to … genre filtering!
#4 by Paul on June 23, 2014 - 2:52 pm
Kelly – the getJSON call makes a call to the server to get artist data from a number of cities based on the given city IDs. The best way to see what is going on is to just open up your developer tools and set breakpoints and inspect the variables. An hour spent learning the developer tools in chrome or firefox will be greatly rewarded. — Paul
#5 by Kelly Maurice on June 23, 2014 - 3:24 pm
Got it, thanks, will try.
#6 by Kelly Maurice on June 23, 2014 - 5:41 pm
I stepped into the getJSON call and I get back a massive block of code that i won’t paste here, and is not that helpful – I guess I don’t see any API on echo nest that starts with the parameter ‘artists’ so I’m stuck at the point. The next demo, Similar Artists Browser uses a getJSON call that has all the URL and other echonest params listed right there so is this a new API or is this some convenience variable you’re using?
#7 by ptrwtts on June 23, 2014 - 7:59 pm
Is there any way to remove tracks? That’s what I was really hoping for. That way you could create dynamic playlists that change over time (e.g. a chart). Any idea if it’s coming?
#8 by Paul on July 23, 2014 - 1:44 pm
Rumor is … coming very soon.
P
#9 by Peter Watts (@ptrwtts) on July 23, 2014 - 2:16 pm
Nice. Very impressed with the speed at which it’s being improved