#!/usr/bin/liquidsoap
#                    .                                       
#     .  ....   ~DMMMM$ .                                    
#     8MMMMMMMMMMMMMMMMMMMD. ..                              
#  .MMMMMMMMMMMMMMMMMMMMMMMMMM~ ..                           
# ..$MMMMMMMMMMMMMMMMMMMMMMMMM88M.                           
#  . MMMMM$MMMMMMMMMMMM?MMMMMMMMM                            
#   .MMMMMMM$MMM$MMMMMMMMMMMMMMM8.                           
#   .MMMMMMMMMMMMMMMMMMMMMMMMMMM?...  . ..   ...  ... . . .  
#    MMMMMMMMMMMMMMMMM. MMMM:~MM.D$   .MM..888M$ ..88D8888.  
#    MMMMMMMM8MMMMMMMM  MM$.MMMM.M$   .MM..M.. ~M. MM  .  .. 
#   .MMMMMMMM$MMMMMMMM. M .MMMMM M?.   MM..M. . M. MM.       
#    ~MMMMMMM$MMMMMMMM.. MMMMMMM.M?.  .MM .MMMMM:  MMMMMMM.. 
#   ..MMMMMMM$MMMMMMMM. M.?MMMMM.M$.   MM..M .. M8.MM .    . 
#     MMMMMMM$MMMMMMMM .MM  MMM$ MM..  M8  M.  .$M.MM.   .   
#   ...MMMMMM$MMMMMMMM  MMM. MM . MM ~MM. .M$$8MM .MM88888.  
#       MMMMM8MMMMMMMMMMMMMMMMM..   ~~ ..... . ..   .     .  
#       .~MMMMMMMMMMMMMMMMMM$ .       . . .     . .     ..   
#         .MMMMMMMMMMMMMM..                                  
#           MMMMMMMMM ....                                   
#          ..MMM?....                                        
#           . ...                                            
#
#       KUBERadio.com
set("log.file.path","/home/liquidsoap/logs/main.log")
set("frame.size",4704)

################
# Sources
studioInput = input.alsa(id="studioInput",bufferize=false)
sustainList = playlist("/home/kube/kube-music/sustain/play.m3u")
###############

################
# KUBE Settings
kubeHost="localhost"
kubePort=8000
kubeUser="source"
kubePassword="OMITTED FOR SECURITY"
kubeGenre="Student radio"
kubeUrl="kuberadio.com"
kubeDesc="Keele University student radio"
#################

studioInput=rewrite_metadata([("artist", "KUBE Radio"),
                        ("title","LIVE Stream,TEXT the studio from kuberadio.com OR TXT KUBE followed by your message to 60300")],studioInput)



#################
# Processing
sustain = nrj(sustainList)

radio = fallback.skip(strip_blank(threshold=-35.,length=15.,studioInput),sustain)
radio=mksafe(radio)

################

#################
# ICECAST MOUNTS
output.icecast(%mp3,radio,mount="kube",id="kubeMP3",name="KUBE Radio HIGH bandwidth",quality=8,bitrate=128,
                    host=kubeHost,port=kubePort,user=kubeUser,password=kubePassword,genre=kubeGenre,url=kubeUrl,description=kubeDesc)
output.icecast(%mp3,radio,mount="kube-low",id="kubeMP3Low",name="KUBE Radio LOW bandwidth",quality=5,bitrate=64,
                host=kubeHost,port=kubePort,user=kubeUser,password=kubePassword,genre=kubeGenre,url=kubeUrl,description=kubeDesc)
output.icecast(%vorbis, radio,mount="kube-low.ogg",id="kubeOggLow",name="KUBE Radio LOW bandwidth",quality=2.,
                    host=kubeHost,port=kubePort,user=kubeUser,password=kubePassword,genre=kubeGenre,url=kubeUrl,description=kubeDesc)
output.icecast(%vorbis, radio,mount="kube.ogg",id="kubeOggHigh",name="KUBE Radio HIGH bandwidth",quality=8.,
                    host=kubeHost,port=kubePort,user=kubeUser,password=kubePassword,genre=kubeGenre,url=kubeUrl,description=kubeDesc)
output.icecast(%vorbis, radio,mount="kube-archive.ogg",id="kubeOggLow",name="KUBE Radio Archive stream",quality=10.,public=false,
                    host=kubeHost,port=kubePort,user=kubeUser,password=kubePassword,genre=kubeGenre,url=kubeUrl,description=kubeDesc)
#################

output.alsa(id="officeOutput",bufferize=false,device="hw:0")
