Advertisement
retesere20

azura-config-liquidsoap

Dec 9th, 2020
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1.  
  2. string(6386) "# Welcome to the AzuraCast Liquidsoap configuration editor.
  3. # Using this page, you can customize several sections of the Liquidsoap configuration.
  4. # The non-editable sections are automatically generated by AzuraCast.
  5.  
  6.  
  7. custom_config_top
  8.  
  9. set("init.daemon", false)
  10. set("init.daemon.pidfile.path","/var/azuracast/stations/stream_soft/config/liquidsoap.pid")
  11. set("log.stdout", true)
  12. set("log.file", false)
  13. set("server.telnet",true)
  14. set("server.telnet.bind_addr","0.0.0.0")
  15. set("server.telnet.port", 8004)
  16. set("harbor.bind_addrs",["0.0.0.0"])
  17.  
  18. set("tag.encodings",["UTF-8","ISO-8859-1"])
  19. set("encoder.encoder.export",["artist","title","album","song"])
  20.  
  21. setenv("TZ", "UTC")
  22.  
  23. azuracast_api_auth = ref "xxxxxx"
  24. ignore(azuracast_api_auth)
  25.  
  26.  
  27. custom_config_pre_playlists
  28.  
  29. playlist_all = playlist(id="playlist_all",mode="randomize",reload_mode="watch",conservative=true,default_duration=10.,length=20.,"/var/azuracast/stations/stream_soft/playlists/playlist_all.m3u")
  30. playlist_all = audio_to_stereo(id="stereo_playlist_all", playlist_all)
  31. playlist_all = cue_cut(id="cue_playlist_all", playlist_all)
  32.  
  33. # Standard Playlists
  34. radio = random(id="stream_soft_standard_playlists", weights=[3], [playlist_all])
  35.  
  36. # AutoDJ Next Song Script
  37. def azuracast_next_song() =
  38. uri = list.hd(get_process_lines(env=[("API_AUTH", !azuracast_api_auth)], 'curl -s --request POST --url http://web/api/internal/1/nextsong --form api_auth="$API_AUTH"'), default="")
  39. log("AzuraCast Raw Response: #{uri}")
  40.  
  41. if uri == "" or string.match(pattern="Error", uri) then
  42. []
  43. else
  44. r = request.create(uri)
  45. if request.resolve(r) then
  46. [r]
  47. else
  48. []
  49. end
  50. end
  51. end
  52.  
  53. dynamic = request.dynamic.list(id="stream_soft_next_song", timeout=20., retry_delay=3., azuracast_next_song)
  54. dynamic = audio_to_stereo(id="stream_soft_stereo_next_song", dynamic)
  55. dynamic = cue_cut(id="stream_soft_cue_next_song", dynamic)
  56. radio = fallback(id="stream_soft_autodj_fallback", track_sensitive = true, [dynamic, radio])
  57.  
  58. requests = request.queue(id="stream_soft_requests")
  59. requests = audio_to_stereo(id="stream_soft_stereo_requests", requests)
  60. requests = cue_cut(id="stream_soft_cue_requests", requests)
  61. radio = fallback(id="stream_soft_requests_fallback", track_sensitive = true, [requests, radio])
  62.  
  63. add_skip_command(radio)
  64.  
  65.  
  66. custom_config_pre_fade
  67.  
  68. radio = crossfade(smart=false, duration=3.00,fade_out=2.00,fade_in=2.00,radio)
  69.  
  70. custom_config_pre_live
  71.  
  72. # DJ Authentication
  73. live_enabled = ref false
  74. last_authenticated_dj = ref ""
  75. live_dj = ref ""
  76.  
  77. def dj_auth(auth_user,auth_pw) =
  78. user = ref ""
  79. password = ref ""
  80.  
  81. if (auth_user == "source" or auth_user == "") and (string.match(pattern="(:|,)+", auth_pw)) then
  82. auth_string = string.split(separator="(:|,)", auth_pw)
  83.  
  84. user := list.nth(default="", auth_string, 0)
  85. password := list.nth(default="", auth_string, 2)
  86. else
  87. user := auth_user
  88. password := auth_pw
  89. end
  90.  
  91. log("Authenticating DJ: #{!user}")
  92.  
  93. ret = list.hd(get_process_lines(env=[("DJ_USER", !user), ("DJ_PASSWORD", !password), ("API_AUTH", !azuracast_api_auth)], 'curl -s --request POST --url http://web/api/internal/1/auth --form dj-user="$DJ_USER" --form dj-password="$DJ_PASSWORD" --form api_auth="$API_AUTH"'), default="")
  94. log("AzuraCast DJ Auth Response: #{ret}")
  95.  
  96. authed = bool_of_string(ret)
  97. if (authed) then
  98. last_authenticated_dj := !user
  99. end
  100.  
  101. authed
  102. end
  103.  
  104. def live_connected(header) =
  105. dj = !last_authenticated_dj
  106. log("DJ Source connected! Last authenticated DJ: #{dj} - #{header}")
  107.  
  108. live_enabled := true
  109. live_dj := dj
  110.  
  111. ret = list.hd(get_process_lines(env=[("DJ_USER", dj), ("API_AUTH", !azuracast_api_auth)], 'curl -s --request POST --url http://web/api/internal/1/djon --form dj-user="$DJ_USER" --form api_auth="$API_AUTH"'), default="")
  112. log("AzuraCast Live Connected Response: #{ret}")
  113. end
  114.  
  115. def live_disconnected() =
  116. dj = !live_dj
  117.  
  118. log("DJ Source disconnected! Current live DJ: #{dj}")
  119.  
  120. ret = list.hd(get_process_lines(env=[("DJ_USER", dj), ("API_AUTH", !azuracast_api_auth)], 'curl -s --request POST --url http://web/api/internal/1/djoff --form dj-user="$DJ_USER" --form api_auth="$API_AUTH"'), default="")
  121. log("AzuraCast Live Disconnected Response: #{ret}")
  122.  
  123. live_enabled := false
  124. last_authenticated_dj := ""
  125. live_dj := ""
  126. end
  127.  
  128. # A Pre-DJ source of radio that can be broadcast if needed
  129. radio_without_live = radio
  130. ignore(radio_without_live)
  131.  
  132. # Live Broadcasting
  133. live = audio_to_stereo(input.harbor("/", id = "stream_soft_input_streamer", port = 8005, auth = dj_auth, icy = true, icy_metadata_charset = "UTF-8", metadata_charset = "UTF-8", on_connect = live_connected, on_disconnect = live_disconnected, buffer = 5.00, max = 10.00))
  134. ignore(output.dummy(live, fallible=true))
  135.  
  136. radio = fallback(id="stream_soft_live_fallback", replay_metadata=false, track_sensitive=false, [live, radio])
  137.  
  138. # Allow for Telnet-driven insertion of custom metadata.
  139. radio = server.insert_metadata(id="custom_metadata", radio)
  140.  
  141. # Apply amplification metadata (if supplied)
  142. radio = amplify(override="liq_amplify", 1., radio)
  143.  
  144. radio = fallback(id="stream_soft_safe_fallback", track_sensitive = false, [radio, single(id="error_jingle", "/usr/local/share/icecast/web/error.mp3")])
  145.  
  146. custom_config
  147.  
  148. # Send metadata changes back to AzuraCast
  149. def metadata_updated(m) =
  150. def f() =
  151. if (m["song_id"] != "") then
  152. ret = list.hd(get_process_lines(env=[("SONG", m["song_id"]), ("MEDIA", m["media_id"]), ("PLAYLIST", m["playlist_id"]), ("API_AUTH", !azuracast_api_auth)], 'curl -s --request POST --url http://web/api/internal/1/feedback --form song="$SONG" --form media="$MEDIA" --form playlist="$PLAYLIST" --form api_auth="$API_AUTH"'), default="")
  153. log("AzuraCast Feedback Response: #{ret}")
  154. end
  155. (-1.)
  156. end
  157.  
  158. add_timeout(fast=false, 0., f)
  159. end
  160.  
  161. radio = on_metadata(metadata_updated,radio)
  162.  
  163. # Local Broadcasts
  164. output.icecast(%mp3(samplerate=44100, stereo=true, bitrate=128, id3v2=true), id="stream_soft_local_1", host = "127.xxx", port = xxxx, password = "xxxxx", mount = "/radio.mp3", name = "Stream Soft", description = "", genre = "", public = false, encoding = "UTF-8", radio)
  165.  
  166. # Remote Relays"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement