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

  1. #!/usr/bin/liquidsoap
  2. set("log.file.path","/tmp/<script>.log")
  3. %include "passwords.liq"
  4. # Print log messages to the console,
  5. set("log.stdout", true)
  6. set("server.telnet",true)
  7. #If the playlist crashes
  8. security = single("~/radio/default.ogg")
  9. #Regular playlist
  10. go = playlist.once("/media/vault/playlist.m3u")
  11. #1. this doesn't work and
  12. #2. who the fuck makes a list read from the back?
  13. #radio = sequence([go, first])
  14. radio = fallback(track_sensitive = false, [go, security])
  15. ###======================= update metadata from telnet==============
  16. def icy_update(v) =
  17. # Parse the argument
  18. l = string.split(separator=",",v)
  19. def split(l,v) =
  20. v = string.split(separator="=",v)
  21. if list.length(v) >= 2 then
  22. list.append(l,[(list.nth(v,0,default=""),list.nth(v,1,default=""))])
  23. else
  24. l
  25. end
  26. end
  27. meta = list.fold(split,[],l)
  28. # Update metadata
  29. icy.update_metadata(mount="/radio",password=ICECAST_SERVER_PASSWORD,
  30. host=ICECAST_SERVER_HOST,meta)
  31. icy.update_metadata(mount="/radio.ogg",password=ICECAST_SERVER_PASSWORD,
  32. host=ICECAST_SERVER_HOST,meta)
  33. "Done !"
  34. end
  35. ###============ register the ability for telnet metadata update =====
  36. server.register("update",namespace="metadata",
  37. description="Update metadata",
  38. usage="update song=..",
  39. icy_update)
  40. ###======= sound collage of 5 seconds(for testing lists) ============
  41. def add_cue_out (m) =
  42. [("liq_cue_in","0"),("liq_cue_out","5")]
  43. end
  44. #==turn on to test playlist generation etc.=========================
  45. #=========== will only play 5 seconds per track ===================
  46. #radio = map_metadata(add_cue_out, radio)
  47. #radio = cue_cut(radio)
  48. #============= shutdown function ===================================
  49. def shutdownhandler()
  50. print("blank detected and shutting down stream")
  51. shutdown()
  52. end
  53. #========= upon 20 seconds of silence shutdown the radio ===========
  54. #====== (end of stream or other problem) ===========================
  55. radio = on_blank(shutdownhandler, radio)
  56. output.icecast(%mp3,
  57. icy_metadata="true",host=ICECAST_SERVER_HOST,port=ICECAST_SERVER_PORT,password=ICECAST_SERVER_PASSWORD,
  58. mount="radio",radio)
  59. output.icecast(%vorbis,
  60. icy_metadata="true",host=ICECAST_SERVER_HOST,port=ICECAST_SERVER_PORT,password=ICECAST_SERVER_PASSWORD,
  61. mount="radio.ogg",radio)