It’s summer, time for a short break (well, if you’re a start-up founder, you know there’s no such thing as a real break), so I decided to hack on something different than our upcoming seevl.fm release (sign-up here for the beta!) to change my mind.
Reviving part of our previous valentun.es hack from MHD NY 2011, here’s Send A Preview.
Send A Preview
SAP is a simple app that let you text an artist name to a dedicated number and get a phone call a few seconds later to let you listen to previews of their top-5 tracks.
It uses the Twilio API (for all SMS and voice interactions), the 7Digital API (for track previews, using their python lib), and Flask (for the HTTP integration and parsing / getting the data), and it runs with Gunicorn and Nginx - while the responsive CSS is provided by Toast. Full source code is on GitHub, under GPL.
The Twilio API is well documented - as well as the Python bindings -, so very easy to implement. For instance, the following lines will create a TwiML to let the user input any one-digit character to play a particular track.
with response.gather(numDigits=1, method="GET", timeout=10, action="/twiml/%s" %(tid)) as gather:
for i in range(1, len(json['tracks'])+1):
gather.say("Press %s to play %s." %(i, json['tracks'][str(i)]['title']))
I got confused by the POST-by-default when accessing a TwiML when passing a phone call: since it queries the existing URL of a TwiML, I’d have expected a GET by default, and a POST only in some cases.
But actually, the painful part happen when accessing the track samples. I first used the iTunes API, before figuring out that Twilio can’t play M4A files. I then switched to the Deezer API - that we’re already using at MDG in various apps - to get MP3 samples. Everything worked fine until I deployed on AWS, where the script failed as Deezer is not available in the US,where our EC2 box is located. I finally switched to 7Digital and their US store, so the app now works fine – at least I suppose for most artists!
The app landing page is at http://sap.mdg.io, and you can use it at +1 347-329-3425 (unless you call at a time our Twilio credits are down!). If you enjoy using it and have particular needs for your own music discovery app, contact us!