init liquidsoap. We thank our uncle Claude, gave him 1.74$ so he can buy a beer. He got drunk on wine and we had to clean the mess ourselves. Sacré oncle Claude !

This commit is contained in:
aethor
2026-01-18 22:30:35 +08:00
parent 9374af6ed5
commit 233389df8f
11 changed files with 257 additions and 200 deletions

137
radio.liq Normal file
View File

@@ -0,0 +1,137 @@
#!/usr/bin/liquidsoap
# Radio Bullshit - Liquidsoap Configuration
# Modern open-source streaming with automatic song/jingle alternation
# ============================================================================
# CONFIGURATION
# ============================================================================
# Get environment variables with defaults
hostname = environment.get(default="localhost", "HOSTNAME")
port = int_of_string(environment.get(default="8000", "PORT"))
# Log configuration
log.file.path := "/var/log/liquidsoap/radio-bullshit.log"
log.level := 3
# ============================================================================
# SOURCES
# ============================================================================
# Songs playlist - reload every 60 seconds to pick up new downloads
songs = playlist(
mode="randomize",
reload=60,
reload_mode="watch",
"/songs/playlist.pls"
)
# Jingles playlist
jingles = playlist(
mode="randomize",
reload=60,
reload_mode="watch",
"/jingles/playlist.pls"
)
# Air support (fallback audio when nothing else is available)
# air_support = playlist(
# mode="randomize",
# reload_mode="watch",
# "/air-support/playlist.pls"
# )
air_support = single("/air-support/Airplane_Sound_Effect.ogg")
# ============================================================================
# ALTERNATING LOGIC
# ============================================================================
# Alternate between songs and jingles: play 1 jingle, then 4 songs
# This creates a pattern: jingle, song, song, song, song, jingle, ...
radio = rotate(
weights=[1, 1],
[jingles, songs]
)
# Add fallback to air support in case of errors
radio = fallback(
track_sensitive=false,
[radio, air_support]
)
# Normalize audio levels for consistent volume
# radio = normalize(radio)
# ============================================================================
# OUTPUTS
# ============================================================================
# Built-in HTTP server (replaces Icecast)
# Serves the stream directly via Liquidsoap's Harbor server
output.harbor(
%mp3(bitrate=128, samplerate=44100),
port=port,
mount="/radio-bullshit",
url="http://#{hostname}:#{port}",
radio
)
# Enable built-in HTTP server for stream and status
settings.harbor.bind_addrs := ["0.0.0.0"]
# Add a simple HTML page
harbor.http.register(
port=port,
method="GET",
"/",
fun (_, response) -> begin
html = "<!DOCTYPE html>
<html>
<head>
<title>Radio Bullshit</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; background: #1a1a1a; color: #fff; }
h1 { color: #ff6b6b; }
audio { margin: 20px; }
a { color: #4ecdc4; }
</style>
</head>
<body>
<h1>Radio Bullshit</h1>
<p>J'ai une superbe opportunit&eacute; de travail</p>
<audio controls autoplay>
<source src=\"/radio-bullshit\" type=\"audio/mpeg\">
Your browser does not support the audio element.
</audio>
<p><a href=\"/radio-bullshit.m3u\">Download M3U Playlist</a></p>
</body>
</html>"
response.html(html)
end
)
# Serve M3U playlist file
harbor.http.register(
port=port,
method="GET",
"/radio-bullshit.m3u",
fun (_, response) -> begin
m3u = "http://#{hostname}:#{port}/radio-bullshit"
response.content_type("audio/x-mpegurl")
response.data(m3u)
end
)
# Status endpoint (JSON)
# harbor.http.register(
# port=port,
# method="GET",
# "/status.json",
# fun (_, response) -> begin
# status = '{"status":"online","stream":"Radio Bullshit","mount":"/radio-bullshit"}'
# response.json(parse_json(status))
# end
# )
log("Radio Bullshit is now streaming on http://#{hostname}:#{port}/radio-bullshit")