Comments in radio script

This commit is contained in:
2024-04-24 20:15:39 +02:00
parent cc11d3f75e
commit 61956e0dab
+24 -6
View File
@@ -7,7 +7,11 @@ let json.parse credentials = file.contents("/home/pi/Conjurer/icecast_credentia
# Enable replaygain metadata processing # Enable replaygain metadata processing
enable_replaygain_metadata() enable_replaygain_metadata()
# Set up a playlog for tracking played tracks
l = playlog(duration = 14400.0, persistency="/home/pi/Conjurer/persistence.log") l = playlog(duration = 14400.0, persistency="/home/pi/Conjurer/persistence.log")
# Function to check if a track can be played based on its metadata
def check(r) def check(r)
m = request.metadata(r) m = request.metadata(r)
if l.last(m) < 3600. then if l.last(m) < 3600. then
@@ -19,13 +23,15 @@ let json.parse credentials = file.contents("/home/pi/Conjurer/icecast_credentia
end end
end end
# Define playlists to be used in the stream # Define playlists to be used in the stream
s1 = replaygain(playlist(reload_mode="watch", check_next=check, "/home/pi/Conjurer/all_playlist.playlist")) s1 = replaygain(playlist(reload_mode="watch", check_next=check, "/home/pi/Conjurer/all_playlist.playlist"))
s2 = replaygain(playlist(reload_mode="watch", check_next=check, "/home/pi/Conjurer/priority_queue.playlist")) s2 = replaygain(playlist(reload_mode="watch", check_next=check, "/home/pi/Conjurer/priority_queue.playlist"))
s3 = replaygain(playlist(reload_mode="watch", check_next=check, "/home/pi/Conjurer/hit.playlist")) s3 = replaygain(playlist(reload_mode="watch", check_next=check, "/home/pi/Conjurer/hit.playlist"))
# Create a request queue for user-generated requests
requests_queue = request.queue() requests_queue = request.queue()
# Function to process the request queue and add new requests
def queue_processing() def queue_processing()
f1=file.read("/home/pi/Conjurer/request.playlist") f1=file.read("/home/pi/Conjurer/request.playlist")
text = f1() text = f1()
@@ -42,16 +48,22 @@ let json.parse credentials = file.contents("/home/pi/Conjurer/icecast_credentia
# Randomly select a playlist with weights # Randomly select a playlist with weights
s4 = random(id="randomizer", weights=[1, 3, 2], [s1, s2, s3]) s4 = random(id="randomizer", weights=[1, 3, 2], [s1, s2, s3])
# Load jingles playlist
jingles = (playlist(reload_mode="watch", "/home/pi/Conjurer/jingles.playlist")) jingles = (playlist(reload_mode="watch", "/home/pi/Conjurer/jingles.playlist"))
# Create the main stream with random playlist and jingles
s = rotate(id="randomizer", weights=[20, 1], [s4, jingles]) s = rotate(id="randomizer", weights=[20, 1], [s4, jingles])
# Set up an interactive harbor for controlling the stream # Set up an interactive harbor for controlling the stream
interactive.harbor(port = 9999) interactive.harbor(port = 9999)
# Set up interactive controls for bass boost # Set up interactive controls for bass boost
f = interactive.float("f", description="Frequency", min=0., max=1000., unit="Hz", 200.) f = interactive.float("f", description="Frequency", min=0., max=1000., unit="Hz", 200.)
g = interactive.float("g", description="Gain", min=0., max=20., unit="dB", 8.) g = interactive.float("g", description="Gain", min=0., max=20., unit="dB", 8.)
b = bass_boost(frequency=f, gain=g, s) b = bass_boost(frequency=f, gain=g, s)
s = add([s, b]) s = add([s, b])
# Set up interactive control for main volume # Set up interactive control for main volume
a = interactive.float("main_volume", min=0., max=20., 1.) a = interactive.float("main_volume", min=0., max=20., 1.)
s = compress.multiband.interactive(bands=3, s) s = compress.multiband.interactive(bands=3, s)
@@ -82,9 +94,7 @@ let json.parse credentials = file.contents("/home/pi/Conjurer/icecast_credentia
cross_s = crossfade(fade_out=3., fade_in=3., duration=5., fallback(id="switcher", track_sensitive=false, [requests_queue, s])) cross_s = crossfade(fade_out=3., fade_in=3., duration=5., fallback(id="switcher", track_sensitive=false, [requests_queue, s]))
radio = fallback(id="switcher2", track_sensitive=false, [cross_s, emergency]) radio = fallback(id="switcher2", track_sensitive=false, [cross_s, emergency])
thread.run(every=60., queue_processing) # Function to process the request queue and skip the current track if requested
p = interactive.bool("r1", false)
def check_skip() def check_skip()
if p() then if p() then
log.info("Skipping current track.") log.info("Skipping current track.")
@@ -92,8 +102,15 @@ let json.parse credentials = file.contents("/home/pi/Conjurer/icecast_credentia
p.set(false) p.set(false)
end end
end end
thread.run(every=5., check_skip)
# Run the queue processing function every 60 seconds
thread.run(every=60., queue_processing)
# Set up an interactive control for skipping tracks
p = interactive.bool("r1", false)
# Run the check_skip function every 5 seconds
thread.run(every=5., check_skip)
# Handle metadata events # Handle metadata events
handle_metadata = fun (m) -> begin handle_metadata = fun (m) -> begin
@@ -109,6 +126,7 @@ let json.parse credentials = file.contents("/home/pi/Conjurer/icecast_credentia
# Configure output formats and destinations # Configure output formats and destinations
output.file.hls("/tmp/hls", [("mp3-low", %mp3(bitrate=96)), ("mp3-hi", %mp3(bitrate=160))], radio) output.file.hls("/tmp/hls", [("mp3-low", %mp3(bitrate=96)), ("mp3-hi", %mp3(bitrate=160))], radio)
output.icecast(%mp3, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="mp3-stream", radio) output.icecast(%mp3, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="mp3-stream", radio)
# Uncomment the following lines to enable additional output formats
# output.icecast(%opus, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="opus-stream", radio) # output.icecast(%opus, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="opus-stream", radio)
# output.icecast(%ogg, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="ogg-stream", radio) # output.icecast(%ogg, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="ogg-stream", radio)
# output.icecast(%aac, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="aac-stream", radio) # output.icecast(%aac, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="aac-stream", radio)