Bunch of small scripts to run a temporary radio stream, automatically. Some liquidsoap, some bash, some pyhton. Combine as if you like Unix. with pipes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

71 lines
2.3 KiB

#!/usr/bin/liquidsoap
set("log.file.path","/tmp/<script>.log")
%include "passwords.liq"
# Print log messages to the console,
set("log.stdout", true)
set("server.telnet",true)
#If the playlist crashes
security = single("~/radio/default.ogg")
#Regular playlist
go = playlist.once("/media/vault/playlist.m3u")
#1. this doesn't work and
#2. who the fuck makes a list read from the back?
#radio = sequence([go, first])
radio = fallback(track_sensitive = false, [go, security])
###======================= update metadata from telnet==============
def icy_update(v) =
# Parse the argument
l = string.split(separator=",",v)
def split(l,v) =
v = string.split(separator="=",v)
if list.length(v) >= 2 then
list.append(l,[(list.nth(v,0,default=""),list.nth(v,1,default=""))])
else
l
end
end
meta = list.fold(split,[],l)
# Update metadata
icy.update_metadata(mount="/radio",password=ICECAST_SERVER_PASSWORD,
host=ICECAST_SERVER_HOST,meta)
icy.update_metadata(mount="/radio.ogg",password=ICECAST_SERVER_PASSWORD,
host=ICECAST_SERVER_HOST,meta)
"Done !"
end
###============ register the ability for telnet metadata update =====
server.register("update",namespace="metadata",
description="Update metadata",
usage="update song=..",
icy_update)
###======= sound collage of 5 seconds(for testing lists) ============
def add_cue_out (m) =
[("liq_cue_in","0"),("liq_cue_out","5")]
end
#==turn on to test playlist generation etc.=========================
#=========== will only play 5 seconds per track ===================
#radio = map_metadata(add_cue_out, radio)
#radio = cue_cut(radio)
#============= shutdown function ===================================
def shutdownhandler()
print("blank detected and shutting down stream")
shutdown()
end
#========= upon 20 seconds of silence shutdown the radio ===========
#====== (end of stream or other problem) ===========================
radio = on_blank(shutdownhandler, radio)
output.icecast(%mp3,
icy_metadata="true",host=ICECAST_SERVER_HOST,port=ICECAST_SERVER_PORT,password=ICECAST_SERVER_PASSWORD,
mount="radio",radio)
output.icecast(%vorbis,
icy_metadata="true",host=ICECAST_SERVER_HOST,port=ICECAST_SERVER_PORT,password=ICECAST_SERVER_PASSWORD,
mount="radio.ogg",radio)