Fixed post flow

This commit is contained in:
Fergal Moran
2015-10-19 21:06:54 +01:00
parent 2013130458
commit 8434b49667
2 changed files with 11 additions and 7 deletions

View File

@@ -88,14 +88,19 @@ class RadioHelper(Helper):
return Response(status=HTTP_200_OK)
if action == 'play':
m = Mix.objects.get(slug=request.query_params.get('slug'))
ice_scrobbler.play(m.get_stream_url())
item = {
'url': m.get_stream_url(),
'slug': m.get_full_url(),
'title': str(m)
}
ice_scrobbler.play(item)
return Response(status=HTTP_200_OK)
if 'update' in request.query_params and 'url' in request.query_params:
activity.post_activity('site:radio_changed', message={
'description': request.query_params.get('update'),
'url': request.query_params.get('url')
})
except:
except Exception as ex:
pass
return Response(status=HTTP_400_BAD_REQUEST)

View File

@@ -42,13 +42,12 @@ def get_server_details():
def shuffle():
url = "http://%s:%s/a/shuffle" % (settings.RADIO_HOST, settings.RADIO_PORT)
r = requests.post(url)
def play(url):
url = "http://%s:%s/a/shuffle" % (settings.RADIO_HOST, settings.RADIO_PORT)
url = "http://{}:{}/a/shuffle".format(settings.RADIO_HOST, settings.RADIO_PORT)
r = requests.post(url)
def play(item):
url = "http://{}:{}/a/play".format(settings.RADIO_HOST, settings.RADIO_PORT)
r = requests.post(url, data=item)
if __name__ == '__main__':
d = get_server_details("localhost", "8000", "dss")