Skip to content

Commit

Permalink
added search method to query rdio search
Browse files Browse the repository at this point in the history
  • Loading branch information
amoskyler committed Apr 12, 2014
1 parent a008ba6 commit 0d85ae7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions queue/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@
import twilio.twiml
from django.views.generic import View
from django.http import HttpResponse

from rdio import Rdio
# Create your views here.

class Queue(View):

def get(self, request):
res = twilio.twiml.Response()
from_number = request.GET['Body']
print from_number
twiml = '<Response><Message>Hello from your Django app!</Message></Response>'
return HttpResponse(twiml+ '/n' + from_number, content_type='text/xml')
body = request.GET['Body']
results = searchRdio(body)

twiml = '<Response><Message>message of ' +body+ ' was recieved</Message></Response>'
res.message("You're song "+results + "has been found")
return HttpResponse(twiml+ '/n' + results, content_type='text/xml')

def searchRdio(query):
rdio = Rdio(("WF00svqcVrTXHv3eHSQO1w"), ("FYAjVfujchx4eTCFAOD8ag"))
results = rdio.call("search", {"query" : query,
"types" : ["Track",],
"extras" : "isExplicit",
"count" : 1})
return results[0]

0 comments on commit 0d85ae7

Please sign in to comment.