Example #1
0
File: app.py Project: brishin/mixr
def randomSong():
  resp = []
  random.seed()
  artists = get_artists()
  if request.headers['Content-Type'] == 'text/plain' or request.headers['Content-Type'] == 'text/html':
    for x in range(0, request.data):
      resp.append(grooveshark.getRandSong(artists[int(math.floor(random.random()*len(artists)))]))
  elif request.headers['Content-Type'] == 'application/json':
    for x in range(0, json.dump(request.json))['rows']:
      resp.append(grooveshark.getRandSong(artists[int(math.floor(random.random()*len(artists)))]))
  elif request.headers['Content-Type'] == 'application/x-www-form-urlencoded' or request.headers['Content-Type'] == 'application/x-www-form-urlencoded; charset=UTF-8' or request.headers['Content-Type'] == 'application/x-www-form-urlencoded; charset=utf-8':
    for x in range(0, int(request.form['rows'])):
      resp.append(grooveshark.getRandSong(artists[int(math.floor(random.random()*len(artists)))]))
  else:
    print "header" + request.headers['Content-Type']
    return "415 Unsupported Media Type ;)"
  js = json.dumps(resp)

  out = Response(js, status=200, mimetype='application/json')
  out.headers['Link'] = 'http://mixr.herokuapp.com'

  return out
Example #2
0
File: app.py Project: brishin/mixr
def getSongFromAlbum(artist):
  grooveshark.getRandSong(artist)