Added extra logging to icecast parser

This commit is contained in:
fergalmoran
2013-06-21 12:32:19 +01:00
parent 6007d42946
commit 3241e32a8f
2 changed files with 15 additions and 13 deletions

View File

@@ -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)

View File

@@ -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