mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-16 14:52:11 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 439c5c753c | |||
| cc11d3f75e | |||
| a35d7da6e3 | |||
| 2c50318f1c | |||
| addc534c36 |
@@ -5,136 +5,156 @@
|
|||||||
# Load icecast credentials from a JSON file
|
# Load icecast credentials from a JSON file
|
||||||
let json.parse credentials = file.contents("/home/pi/Conjurer/icecast_credentials.json")
|
let json.parse credentials = file.contents("/home/pi/Conjurer/icecast_credentials.json")
|
||||||
|
|
||||||
# Enable replaygain metadata processing
|
# Enable replaygain metadata processing
|
||||||
enable_replaygain_metadata()
|
enable_replaygain_metadata()
|
||||||
l = playlog(duration = 14400.0, persistency="/home/pi/Conjurer/persistence.log")
|
|
||||||
def check(r)
|
# Set up a playlog for tracking played tracks
|
||||||
m = request.metadata(r)
|
l = playlog(duration = 14400.0, persistency="/home/pi/Conjurer/persistence.log")
|
||||||
if l.last(m) < 3600. then
|
|
||||||
log.info("Rejecting #{m['filename']} (played #{l.last(m)}s ago).")
|
# Function to check if a track can be played based on its metadata
|
||||||
false
|
def check(r)
|
||||||
else
|
m = request.metadata(r)
|
||||||
l.add(m)
|
if l.last(m) < 3600. then
|
||||||
true
|
log.info("Rejecting #{m['filename']} (played #{l.last(m)}s ago).")
|
||||||
end
|
false
|
||||||
|
else
|
||||||
|
l.add(m)
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Define playlists to be used in the stream
|
||||||
|
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"))
|
||||||
|
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()
|
||||||
|
|
||||||
# Define playlists to be used in the stream
|
# Function to process the request queue and add new requests
|
||||||
s1 = replaygain(playlist(reload_mode="watch", check_next=check, "/home/pi/Conjurer/all_playlist.playlist"))
|
def queue_processing()
|
||||||
s2 = replaygain(playlist(reload_mode="watch", check_next=check, "/home/pi/Conjurer/priority_queue.playlist"))
|
f1=file.read("/home/pi/Conjurer/request.playlist")
|
||||||
s3 = replaygain(playlist(reload_mode="watch", check_next=check, "/home/pi/Conjurer/hit.playlist"))
|
text = f1()
|
||||||
requests_queue = request.queue()
|
if text != "" then
|
||||||
def queue_processing()
|
requests_queue.push.uri(text)
|
||||||
f1=file.read("/home/pi/Conjurer/request.playlist")
|
file.remove("/home/pi/Conjurer/request.playlist")
|
||||||
text = f1()
|
f = file.open("/home/pi/Conjurer/request.playlist", create=true)
|
||||||
if text != "" then
|
f.close()
|
||||||
requests_queue.push.uri(text)
|
log.info("done")
|
||||||
file.remove("/home/pi/Conjurer/request.playlist")
|
else
|
||||||
f = file.open("/home/pi/Conjurer/request.playlist", create=true)
|
log.info("no requests")
|
||||||
f.close()
|
|
||||||
log.info("done")
|
|
||||||
else
|
|
||||||
log.info("no requests")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Randomly select a playlist with weights
|
# Randomly select a playlist with weights
|
||||||
s = random(id="randomizer", weights=[1, 3, 2], [s1, s2, s3])
|
s4 = random(id="randomizer", weights=[1, 3, 2], [s1, s2, s3])
|
||||||
#s = delay(duration=5., s)
|
|
||||||
#radio = add([delay(1800., jingles), music])
|
|
||||||
#radio = fallback([delay(1800., jingles), music])
|
|
||||||
#p = predicate.signal()
|
|
||||||
#radio = switch([(p, jingles), ({true}, music)])
|
|
||||||
#thread.run(every=1200., {p.signal()})
|
|
||||||
# def cmd(_)
|
|
||||||
# p.signal()
|
|
||||||
# "Jingle inserted!"
|
|
||||||
# end
|
|
||||||
# server.register("insert_jingle", cmd)
|
|
||||||
|
|
||||||
# Set up an interactive harbor for controlling the stream
|
# Load jingles playlist
|
||||||
interactive.harbor(port = 9999)
|
jingles = (playlist(reload_mode="watch", "/home/pi/Conjurer/jingles.playlist"))
|
||||||
# Set up interactive controls for bass boost
|
|
||||||
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.)
|
|
||||||
b = bass_boost(frequency=f, gain=g, s)
|
|
||||||
s = add([s, b])
|
|
||||||
# Set up interactive control for main volume
|
|
||||||
a = interactive.float("main_volume", min=0., max=20., 1.)
|
|
||||||
s = compress.multiband.interactive(bands=3, s)
|
|
||||||
|
|
||||||
# Apply audio processing effects
|
# Create the main stream with random playlist and jingles
|
||||||
s = nrj(normalize(s))
|
s = rotate(id="randomizer", weights=[20, 1], [s4, jingles])
|
||||||
s = amplify(a, s)
|
|
||||||
|
|
||||||
# Skip blank sections in the stream
|
# Set up an interactive harbor for controlling the stream
|
||||||
s = blank.skip(max_blank=2., s)
|
interactive.harbor(port = 9999)
|
||||||
|
|
||||||
# Configure logging settings
|
# Set up interactive controls for bass boost
|
||||||
log_to_stdout = true
|
f = interactive.float("f", description="Frequency", min=0., max=1000., unit="Hz", 200.)
|
||||||
log_to_file = true
|
g = interactive.float("g", description="Gain", min=0., max=20., unit="dB", 8.)
|
||||||
logpath = "/home/pi/Conjurer/radio_log.log"
|
b = bass_boost(frequency=f, gain=g, s)
|
||||||
loglevel = 4
|
s = add([s, b])
|
||||||
set("log.stdout", log_to_stdout)
|
|
||||||
set("log.level", loglevel)
|
|
||||||
|
|
||||||
# Enable logging to file
|
# Set up interactive control for main volume
|
||||||
set("log.file", log_to_file)
|
a = interactive.float("main_volume", min=0., max=20., 1.)
|
||||||
set("log.file.path", logpath)
|
s = compress.multiband.interactive(bands=3, s)
|
||||||
|
|
||||||
# Set up emergency fallback track
|
# Apply audio processing effects
|
||||||
emergency = single("/home/pi/RetroPie/mp3/Youtube/Dr. Peacock - Trip to Ireland [GvrvQTUbUcA].mp3")
|
s = nrj(normalize(s))
|
||||||
|
s = amplify(a, s)
|
||||||
|
|
||||||
# Create a fallback stream with the main stream and emergency track
|
# Skip blank sections in the stream
|
||||||
cross_s = crossfade(fade_out=3., fade_in=3., duration=5., fallback(id="switcher", track_sensitive=false, [requests_queue, s]))
|
s = blank.skip(max_blank=2., s)
|
||||||
radio = fallback(id="switcher2", track_sensitive=false, [cross_s, emergency])
|
|
||||||
|
|
||||||
thread.run(every=60., queue_processing)
|
# Configure logging settings
|
||||||
|
log_to_stdout = true
|
||||||
|
log_to_file = true
|
||||||
|
logpath = "/home/pi/Conjurer/radio_log.log"
|
||||||
|
loglevel = 4
|
||||||
|
set("log.stdout", log_to_stdout)
|
||||||
|
set("log.level", loglevel)
|
||||||
|
|
||||||
# Handle metadata events
|
# Enable logging to file
|
||||||
handle_metadata = fun (m) -> begin
|
set("log.file", log_to_file)
|
||||||
log.info(m["title"])
|
set("log.file.path", logpath)
|
||||||
log.info(m["artist"])
|
|
||||||
log.info(m["filename"])
|
# Set up emergency fallback track
|
||||||
|
emergency = single("/home/pi/RetroPie/mp3/Youtube/Dr. Peacock - Trip to Ireland [GvrvQTUbUcA].mp3")
|
||||||
|
|
||||||
|
# Create a fallback stream with the main stream and emergency track
|
||||||
|
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])
|
||||||
|
|
||||||
|
# Function to process the request queue and skip the current track if requested
|
||||||
|
def check_skip()
|
||||||
|
if p() then
|
||||||
|
log.info("Skipping current track.")
|
||||||
|
radio.skip()
|
||||||
|
p.set(false)
|
||||||
end
|
end
|
||||||
radio.on_metadata(handle_metadata)
|
end
|
||||||
|
|
||||||
# Enable persistent script parameters
|
# Run the queue processing function every 60 seconds
|
||||||
interactive.persistent("script.params")
|
thread.run(every=60., queue_processing)
|
||||||
|
|
||||||
# Configure output formats and destinations
|
# Set up an interactive control for skipping tracks
|
||||||
output.file.hls("/tmp/hls", [("mp3-low", %mp3(bitrate=96)), ("mp3-hi", %mp3(bitrate=160))], radio)
|
p = interactive.bool("r1", false)
|
||||||
output.icecast(%mp3, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="mp3-stream", radio)
|
|
||||||
# output.icecast(%opus, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="opus-stream", radio)
|
# Run the check_skip function every 5 seconds
|
||||||
# output.icecast(%ogg, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="ogg-stream", radio)
|
thread.run(every=5., check_skip)
|
||||||
# output.icecast(%aac, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="aac-stream", radio)
|
|
||||||
# output.icecast(%flac, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="flac-stream", radio)
|
# Handle metadata events
|
||||||
# output.icecast(%vorbis, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="vorbis-stream", radio)
|
handle_metadata = fun (m) -> begin
|
||||||
# output.icecast(%speex, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="speex-stream", radio)
|
log.info(m["title"])
|
||||||
# output.icecast(%wav, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="wav-stream", radio)
|
log.info(m["artist"])
|
||||||
# output.icecast(%pcm, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="pcm-stream", radio)
|
log.info(m["filename"])
|
||||||
# output.icecast(%raw, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="raw-stream", radio)
|
end
|
||||||
# output.icecast(%s16l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s16l-stream", radio)
|
radio.on_metadata(handle_metadata)
|
||||||
# output.icecast(%s16b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s16b-stream", radio)
|
|
||||||
# output.icecast(%s24l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s24l-stream", radio)
|
# Enable persistent script parameters
|
||||||
# output.icecast(%s24b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s24b-stream", radio)
|
interactive.persistent("script.params")
|
||||||
# output.icecast(%s32l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s32l-stream", radio)
|
|
||||||
# output.icecast(%s32b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s32b-stream", radio)
|
# Configure output formats and destinations
|
||||||
# output.icecast(%s64l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s64l-stream", radio)
|
output.file.hls("/tmp/hls", [("mp3-low", %mp3(bitrate=96)), ("mp3-hi", %mp3(bitrate=160))], radio)
|
||||||
# output.icecast(%s64b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s64b-stream", radio)
|
output.icecast(%mp3, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="mp3-stream", radio)
|
||||||
# output.icecast(%s128l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s128l-stream", radio)
|
# Uncomment the following lines to enable additional output formats
|
||||||
# output.icecast(%s128b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s128b-stream", radio)
|
# output.icecast(%opus, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="opus-stream", radio)
|
||||||
# output.icecast(%s256l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s256l-stream", radio)
|
# output.icecast(%ogg, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="ogg-stream", radio)
|
||||||
# output.icecast(%s256b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s256b-stream", radio)
|
# output.icecast(%aac, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="aac-stream", radio)
|
||||||
# output.icecast(%s512l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s512l-stream", radio)
|
# output.icecast(%flac, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="flac-stream", radio)
|
||||||
# output.icecast(%s512b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s512b-stream", radio)
|
# output.icecast(%vorbis, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="vorbis-stream", radio)
|
||||||
# output.icecast(%s1024l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s1024l-stream", radio)
|
# output.icecast(%speex, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="speex-stream", radio)
|
||||||
# output.icecast(%s1024b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s1024b-stream", radio)
|
# output.icecast(%wav, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="wav-stream", radio)
|
||||||
# output.icecast(%s2048l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s2048l-stream", radio)
|
# output.icecast(%pcm, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="pcm-stream", radio)
|
||||||
# output.icecast(%s2048b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s2048b-stream", radio)
|
# output.icecast(%raw, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="raw-stream", radio)
|
||||||
# output.icecast(%s4096l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s4096l-stream", radio)
|
# output.icecast(%s16l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s16l-stream", radio)
|
||||||
# output.icecast(%s4096b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s4096b-stream", radio)
|
# output.icecast(%s16b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s16b-stream", radio)
|
||||||
# output.icecast(%s8192l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s8192l-stream", radio)
|
# output.icecast(%s24l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s24l-stream", radio)
|
||||||
# output.icecast(%s8192b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s8192b-stream", radio)
|
# output.icecast(%s24b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s24b-stream", radio)
|
||||||
|
# output.icecast(%s32l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s32l-stream", radio)
|
||||||
|
# output.icecast(%s32b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s32b-stream", radio)
|
||||||
|
# output.icecast(%s64l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s64l-stream", radio)
|
||||||
|
# output.icecast(%s64b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s64b-stream", radio)
|
||||||
|
# output.icecast(%s128l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s128l-stream", radio)
|
||||||
|
# output.icecast(%s128b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s128b-stream", radio)
|
||||||
|
# output.icecast(%s256l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s256l-stream", radio)
|
||||||
|
# output.icecast(%s256b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s256b-stream", radio)
|
||||||
|
# output.icecast(%s512l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s512l-stream", radio)
|
||||||
|
# output.icecast(%s512b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s512b-stream", radio)
|
||||||
|
# output.icecast(%s1024l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s1024l-stream", radio)
|
||||||
|
# output.icecast(%s1024b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s1024b-stream", radio)
|
||||||
|
# output.icecast(%s2048l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s2048l-stream", radio)
|
||||||
|
# output.icecast(%s2048b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s2048b-stream", radio)
|
||||||
|
# output.icecast(%s4096l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s4096l-stream", radio)
|
||||||
|
# output.icecast(%s4096b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s4096b-stream", radio)
|
||||||
|
# output.icecast(%s8192l, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s8192l-stream", radio)
|
||||||
|
# output.icecast(%s8192b, host="retropie", port=8000, password=credentials.password, icy_metadata="true", mount="s8192b-stream", radio)
|
||||||
|
|||||||
Reference in New Issue
Block a user