diff --git a/api/helpers.py b/api/helpers.py index 7065a6b..f41a120 100644 --- a/api/helpers.py +++ b/api/helpers.py @@ -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) diff --git a/core/radio/ice_scrobbler.py b/core/radio/ice_scrobbler.py index fb47d47..9be7b93 100644 --- a/core/radio/ice_scrobbler.py +++ b/core/radio/ice_scrobbler.py @@ -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")