Refactor some stuff related to four streams, Liquidsoap is a piece of

shit too - no dynamic variables
This commit is contained in:
Albert Santoni 2015-03-10 19:15:38 -04:00
parent 6232e3f4f0
commit 0042fb50fe
9 changed files with 130 additions and 221 deletions

View file

@ -10,18 +10,23 @@ def generate_liquidsoap_config(ss):
fh.write("################################################\n")
fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n")
fh.write("################################################\n")
fh.write("# The ignore() lines are to squash unused variable warnings\n")
for d in data:
key = d['keyname']
for key, value in data.iteritems():
try:
str_buffer = "%s = %s\n" % (key, int(value))
except ValueError:
try: # Is it a boolean?
if "true" in value or "false" in value:
str_buffer = "%s = %s\n" % (key, value.lower())
else:
raise ValueError() # Just drop into the except below
except: #Everything else is a string
str_buffer = "%s = \"%s\"\n" % (key, value)
str_buffer = d[u'keyname'] + " = "
if d[u'type'] == 'string':
val = '"%s"' % d['value']
else:
val = d[u'value']
val = val if len(val) > 0 else "0"
str_buffer = "%s = %s\n" % (key, val)
fh.write(str_buffer.encode('utf-8'))
# ignore squashes unused variable errors from Liquidsoap
fh.write(("ignore(%s)\n" % key).encode('utf-8'))
fh.write('log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"\n')
fh.close()

View file

@ -104,7 +104,7 @@ server.register(namespace="vars",
fun (s) -> begin log("vars.bootup_time") time := s s end)
server.register(namespace="streams",
"connection_status",
fun (s) -> begin log("streams.connection_status") "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected}:#{!s4_connected}" end)
fun (s) -> begin log("streams.connection_status") "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected},4:#{!s4_connected}" end)
server.register(namespace="vars",
"default_dj_fade",
fun (s) -> begin log("vars.default_dj_fade") default_dj_fade := float_of_string(s) s end)
@ -400,9 +400,9 @@ if s3_enable == true then
s3_connected, s3_description, s3_channels)
end
%ifdef s4_enable
s4_namespace = ref ''
if s4_enable == true then
log("Stream 4 Enabled")
if s4_output == 'shoutcast' then
s4_namespace := "shoutcast_stream_4"
else
@ -413,7 +413,6 @@ if s4_enable == true then
s4_mount, s4_url, s4_name, s4_genre, s4_user, s, "4",
s4_connected, s4_description, s4_channels)
end
%endif
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --liquidsoap-started &"