diff --git a/core/utils/live.py b/core/utils/live.py index eab7b27..2e6efc1 100644 --- a/core/utils/live.py +++ b/core/utils/live.py @@ -38,8 +38,7 @@ def get_server_details(server, port, mount): return None except urllib2.URLError: - print "Unable to read url, please check your parameters" - return "Unknown stream" + return "Unknown stream %s" % server def get_now_playing(server, port, mount): return get_server_details(server, port, mount) diff --git a/spa/ajax.py b/spa/ajax.py index 3f8a3b3..6177b1a 100644 --- a/spa/ajax.py +++ b/spa/ajax.py @@ -5,7 +5,7 @@ from django.conf.urls import url from django.contrib.auth.decorators import login_required from django.core.exceptions import ObjectDoesNotExist from django.db.models import get_model -from django.http import HttpResponse +from django.http import HttpResponse, HttpResponseNotFound from annoying.decorators import render_to from django.shortcuts import render_to_response from django.utils import simplejson @@ -122,16 +122,19 @@ def live_now_playing(request): localsettings.JS_SETTINGS['LIVE_STREAM_URL'], localsettings.JS_SETTINGS['LIVE_STREAM_PORT'], localsettings.JS_SETTINGS['LIVE_STREAM_MOUNT']) - if now_playing_info is not None: - return HttpResponse( - simplejson.dumps({ - 'stream_url': 'http://%s:%s/%s' % ( - localsettings.JS_SETTINGS['LIVE_STREAM_URL'], - localsettings.JS_SETTINGS['LIVE_STREAM_PORT'], - localsettings.JS_SETTINGS['LIVE_STREAM_MOUNT']), - 'description': now_playing_info['stream_description'], - 'title': now_playing_info['current_song'] - }), mimetype="application/json") + try: + if now_playing_info is not None: + return HttpResponse( + simplejson.dumps({ + 'stream_url': 'http://%s:%s/%s' % ( + localsettings.JS_SETTINGS['LIVE_STREAM_URL'], + localsettings.JS_SETTINGS['LIVE_STREAM_PORT'], + localsettings.JS_SETTINGS['LIVE_STREAM_MOUNT']), + 'description': now_playing_info['stream_description'], + 'title': now_playing_info['current_song'] + }), mimetype="application/json") + except: + return HttpResponseNotFound(now_playing_info) return None