l radio: reimplement in liquidsoap
This commit is contained in:
parent
4c057b9929
commit
610cd87749
@ -1,85 +1,47 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
with pkgs.stockholm.lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
name = "radio";
|
name = "radio";
|
||||||
|
|
||||||
music_dir = "/home/radio/music";
|
music_dir = "/home/radio/music";
|
||||||
|
|
||||||
add_random = pkgs.writeDashBin "add_random" ''
|
skip_track = pkgs.writers.writeBashBin "skip_track" ''
|
||||||
${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.findutils}/bin/find "${music_dir}/the_playlist" \
|
|
||||||
| grep -Ev '/other/|/.graveyard/' \
|
|
||||||
| grep '\.ogg$' \
|
|
||||||
| shuf -n1 \
|
|
||||||
| sed 's,${music_dir}/,,' \
|
|
||||||
)"
|
|
||||||
'';
|
|
||||||
|
|
||||||
get_current_track_position = pkgs.writeDash "get_current_track_position" ''
|
|
||||||
${pkgs.mpc_cli}/bin/mpc status | ${pkgs.gawk}/bin/awk '/^\[playing\]/ { sub(/\/.+/,"",$3); split($3,a,/:/); print a[1]*60+a[2] }'
|
|
||||||
'';
|
|
||||||
|
|
||||||
skip_track = pkgs.writeBashBin "skip_track" ''
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
${add_random}/bin/add_random
|
# TODO come up with new rating, without moving files
|
||||||
music_dir=${escapeShellArg music_dir}
|
# music_dir=${lib.escapeShellArg music_dir}
|
||||||
current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%)
|
# current_track=$(${pkgs.curl}/bin/curl -fSs http://localhost:8002/current | ${pkgs.jq}/bin/jq -r .filename)
|
||||||
track_infos=$(${print_current}/bin/print_current)
|
# track_infos=$(${print_current}/bin/print_current)
|
||||||
skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$music_dir"/"$current_track" || echo 0)
|
# skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$current_track" || echo 0)
|
||||||
if [[ "$current_track" =~ ^the_playlist/music/.* ]] && [ "$skip_count" -le 2 ]; then
|
# if [[ "$current_track" =~ .*/the_playlist/music/.* ]] && [ "$skip_count" -le 2 ]; then
|
||||||
skip_count=$((skip_count+1))
|
# skip_count=$((skip_count+1))
|
||||||
${pkgs.attr}/bin/setfattr -n user.skip_count -v "$skip_count" "$music_dir"/"$current_track"
|
# ${pkgs.attr}/bin/setfattr -n user.skip_count -v "$skip_count" "$current_track"
|
||||||
echo skipping: "$track_infos" skip_count: "$skip_count"
|
# echo skipping: "$track_infos" skip_count: "$skip_count"
|
||||||
else
|
# else
|
||||||
mkdir -p "$music_dir"/the_playlist/.graveyard/
|
# mkdir -p "$music_dir"/the_playlist/.graveyard/
|
||||||
mv "$music_dir"/"$current_track" "$music_dir"/the_playlist/.graveyard/
|
# mv "$current_track" "$music_dir"/the_playlist/.graveyard/
|
||||||
echo killing: "$track_infos"
|
# echo killing: "$track_infos"
|
||||||
fi
|
# fi
|
||||||
${pkgs.mpc_cli}/bin/mpc -q next
|
${pkgs.curl}/bin/curl -X POST http://localhost:8002/skip
|
||||||
'';
|
'';
|
||||||
|
|
||||||
good_track = pkgs.writeBashBin "good_track" ''
|
good_track = pkgs.writeBashBin "good_track" ''
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
music_dir=${escapeShellArg music_dir}
|
music_dir=${lib.escapeShellArg music_dir}
|
||||||
current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%)
|
current_track=$(${pkgs.curl}/bin/curl -fSs http://localhost:8002/current | ${pkgs.jq}/bin/jq -r .filename)
|
||||||
track_infos=$(${print_current}/bin/print_current)
|
track_infos=$(${print_current}/bin/print_current)
|
||||||
if [[ "$current_track" =~ ^the_playlist/music/.* ]]; then
|
# TODO come up with new rating, without moving files
|
||||||
${pkgs.attr}/bin/setfattr -n user.skip_count -v 0 "$music_dir"/"$current_track"
|
# if [[ "$current_track" =~ .*/the_playlist/music/.* ]]; then
|
||||||
else
|
# ${pkgs.attr}/bin/setfattr -n user.skip_count -v 0 "$current_track"
|
||||||
mv "$music_dir"/"$current_track" "$music_dir"/the_playlist/music/ || :
|
# else
|
||||||
fi
|
# mv "$current_track" "$music_dir"/the_playlist/music/ || :
|
||||||
|
# fi
|
||||||
echo good: "$track_infos"
|
echo good: "$track_infos"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
track_youtube_link = pkgs.writeDash "track_youtube_link" ''
|
|
||||||
${pkgs.mpc_cli}/bin/mpc current -f %file% \
|
|
||||||
| ${pkgs.gnused}/bin/sed 's@.*\(.\{11\}\)\.ogg@https://www.youtube.com/watch?v=\1@'
|
|
||||||
'';
|
|
||||||
|
|
||||||
print_current = pkgs.writeDashBin "print_current" ''
|
print_current = pkgs.writeDashBin "print_current" ''
|
||||||
echo "$(${pkgs.mpc_cli}/bin/mpc current -f %file%) \
|
${pkgs.curl}/bin/curl -fSs http://localhost:8002/current | ${pkgs.jq}/bin/jq -r '"\(.filename): \(.purl)"'
|
||||||
$(${track_youtube_link})"
|
|
||||||
'';
|
|
||||||
|
|
||||||
print_current_json = pkgs.writeDashBin "print_current_json" ''
|
|
||||||
${pkgs.jq}/bin/jq -n -c \
|
|
||||||
--arg name "$(${pkgs.mpc_cli}/bin/mpc current)" \
|
|
||||||
--arg artist "$(${pkgs.mpc_cli}/bin/mpc current -f %artist%)" \
|
|
||||||
--arg title "$(${pkgs.mpc_cli}/bin/mpc current -f %title%)" \
|
|
||||||
--arg filename "$(${pkgs.mpc_cli}/bin/mpc current -f %file%)" \
|
|
||||||
--arg position "$(${get_current_track_position})" \
|
|
||||||
--arg length "$(${pkgs.mpc_cli}/bin/mpc current -f %time%)" \
|
|
||||||
--arg youtube "$(${track_youtube_link})" '{
|
|
||||||
name: $name,
|
|
||||||
artist: $artist,
|
|
||||||
title: $title,
|
|
||||||
filename: $filename,
|
|
||||||
position: $position,
|
|
||||||
length: $length,
|
|
||||||
youtube: $youtube
|
|
||||||
}'
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
set_irc_topic = pkgs.writeDash "set_irc_topic" ''
|
set_irc_topic = pkgs.writeDash "set_irc_topic" ''
|
||||||
@ -113,15 +75,14 @@ in {
|
|||||||
users.users = {
|
users.users = {
|
||||||
"${name}" = rec {
|
"${name}" = rec {
|
||||||
inherit name;
|
inherit name;
|
||||||
createHome = mkForce false;
|
createHome = lib.mkForce false;
|
||||||
group = name;
|
group = name;
|
||||||
uid = genid_uint31 name;
|
uid = pkgs.stockholm.lib.genid_uint31 name;
|
||||||
description = "radio manager";
|
description = "radio manager";
|
||||||
home = "/home/${name}";
|
home = "/home/${name}";
|
||||||
useDefaultShell = true;
|
useDefaultShell = true;
|
||||||
openssh.authorizedKeys.keys = with config.krebs.users; [
|
openssh.authorizedKeys.keys = with config.krebs.users; [
|
||||||
lass.pubkey
|
lass.pubkey
|
||||||
lass-mors.pubkey
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -131,50 +92,35 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
krebs.per-user.${name}.packages = with pkgs; [
|
krebs.per-user.${name}.packages = with pkgs; [
|
||||||
add_random
|
|
||||||
good_track
|
good_track
|
||||||
skip_track
|
skip_track
|
||||||
print_current
|
print_current
|
||||||
print_current_json
|
|
||||||
ncmpcpp
|
|
||||||
mpc_cli
|
|
||||||
];
|
];
|
||||||
|
|
||||||
services.mpd = {
|
services.liquidsoap.streams.radio = ./radio.liq;
|
||||||
enable = true;
|
systemd.services.radio = {
|
||||||
user = "radio";
|
environment = {
|
||||||
musicDirectory = "${music_dir}";
|
RADIO_PORT = "8002";
|
||||||
dataDir = "/home/radio/state"; # TODO create this somwhere
|
HOOK_TRACK_CHANGE = pkgs.writers.writeDash "on_change" ''
|
||||||
extraConfig = ''
|
set -xefu
|
||||||
log_level "default"
|
LIMIT=1000 #how many tracks to keep in the history
|
||||||
auto_update "yes"
|
HISTORY_FILE=/var/lib/radio/recent
|
||||||
volume_normalization "yes"
|
|
||||||
|
|
||||||
audio_output {
|
listeners=$(${pkgs.curl}/bin/curl -fSs lassul.us:8000/status-json.xsl |
|
||||||
type "httpd"
|
${pkgs.jq}/bin/jq '[.icestats.source[].listeners] | add' || echo 0)
|
||||||
name "raw radio"
|
echo "$(${pkgs.coreutils}/bin/date -Is)" "$filename" | ${pkgs.coreutils}/bin/tee -a "$HISTORY_FILE"
|
||||||
encoder "wave"
|
echo "$(${pkgs.coreutils}/bin/tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE"
|
||||||
port "7900"
|
${set_irc_topic} "playing: $filename listeners: $listeners"
|
||||||
format "44100:16:2"
|
'';
|
||||||
always_on "yes" # prevent MPD from disconnecting all listeners when playback is stopped.
|
MUSIC = "${music_dir}/the_playlist";
|
||||||
tags "yes" # httpd supports sending tags to listening streams.
|
ICECAST_HOST = "localhost";
|
||||||
}
|
};
|
||||||
'';
|
path = [
|
||||||
|
pkgs.yt-dlp
|
||||||
|
];
|
||||||
|
serviceConfig.User = lib.mkForce "radio";
|
||||||
};
|
};
|
||||||
services.liquidsoap.streams.radio-news = pkgs.writeText "radio-news.liq" ''
|
|
||||||
source = mksafe(input.http("http://localhost:7900/raw.wave"))
|
|
||||||
|
|
||||||
output.icecast(mount = '/music.ogg', password = 'hackme', %vorbis(quality = 1), source)
|
|
||||||
output.icecast(mount = '/music.mp3', password = 'hackme', %mp3.vbr(), source)
|
|
||||||
output.icecast(mount = '/music.opus', password = 'hackme', %opus(bitrate = 96), source)
|
|
||||||
|
|
||||||
extra_input = amplify(1.4, audio_to_stereo(input.harbor("live", port=1338)))
|
|
||||||
|
|
||||||
o = smooth_add(normal = source, special = extra_input)
|
|
||||||
output.icecast(mount = '/radio.ogg', password = 'hackme', %vorbis(quality = 1), o)
|
|
||||||
output.icecast(mount = '/radio.mp3', password = 'hackme', %mp3.vbr(), o)
|
|
||||||
output.icecast(mount = '/radio.opus', password = 'hackme', %opus(bitrate = 96), o)
|
|
||||||
'';
|
|
||||||
services.icecast = {
|
services.icecast = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hostname = "radio.lassul.us";
|
hostname = "radio.lassul.us";
|
||||||
@ -195,73 +141,8 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.timers.radio = {
|
|
||||||
description = "radio autoadder timer";
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
|
|
||||||
timerConfig = {
|
|
||||||
OnCalendar = "*:0/1";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.radio = let
|
|
||||||
autoAdd = pkgs.writeDash "autoAdd" ''
|
|
||||||
LIMIT=$1 #in seconds
|
|
||||||
|
|
||||||
timeLeft () {
|
|
||||||
playlistDuration=$(${pkgs.mpc_cli}/bin/mpc --format '%time%' playlist | ${pkgs.gawk}/bin/awk -F ':' 'BEGIN{t=0} {t+=$1*60+$2} END{print t}')
|
|
||||||
currentTime=$(${get_current_track_position})
|
|
||||||
expr ''${playlistDuration:-0} - ''${currentTime:-0}
|
|
||||||
}
|
|
||||||
|
|
||||||
if test $(timeLeft) -le $LIMIT; then
|
|
||||||
${add_random}/bin/add_random
|
|
||||||
fi
|
|
||||||
${pkgs.mpc_cli}/bin/mpc play > /dev/null
|
|
||||||
'';
|
|
||||||
in {
|
|
||||||
description = "radio playlist autoadder";
|
|
||||||
after = [ "network.target" ];
|
|
||||||
|
|
||||||
restartIfChanged = true;
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = "${autoAdd} 150";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.radio-recent = let
|
|
||||||
recentlyPlayed = pkgs.writeDash "recentlyPlayed" ''
|
|
||||||
set -xefu
|
|
||||||
LIMIT=1000 #how many tracks to keep in the history
|
|
||||||
HISTORY_FILE=/var/lib/radio/recent
|
|
||||||
while :; do
|
|
||||||
${pkgs.mpc_cli}/bin/mpc idle player > /dev/null
|
|
||||||
${pkgs.mpc_cli}/bin/mpc current -f %file%
|
|
||||||
done | while read track; do
|
|
||||||
|
|
||||||
listeners=$(${pkgs.curl}/bin/curl lassul.us:8000/status-json.xsl |
|
|
||||||
${pkgs.jq}/bin/jq '[.icestats.source[].listeners] | add')
|
|
||||||
echo "$(date -Is)" "$track" | tee -a "$HISTORY_FILE"
|
|
||||||
echo "$(tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE"
|
|
||||||
${set_irc_topic} "playing: $track listeners: $listeners"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
in {
|
|
||||||
description = "radio recently played";
|
|
||||||
after = [ "mpd.service" "network.target" ];
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
|
|
||||||
restartIfChanged = true;
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = recentlyPlayed;
|
|
||||||
User = "radio";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# allow reaktor2 to modify files
|
# allow reaktor2 to modify files
|
||||||
systemd.services."reaktor2-the_playlist".serviceConfig.DynamicUser = mkForce false;
|
systemd.services."reaktor2-the_playlist".serviceConfig.DynamicUser = lib.mkForce false;
|
||||||
|
|
||||||
krebs.reaktor2.the_playlist = {
|
krebs.reaktor2.the_playlist = {
|
||||||
hostname = "irc.hackint.org";
|
hostname = "irc.hackint.org";
|
||||||
@ -318,13 +199,6 @@ in {
|
|||||||
};
|
};
|
||||||
script = ''. ${pkgs.writeDash "radio" ''
|
script = ''. ${pkgs.writeDash "radio" ''
|
||||||
case "$Method $Request_URI" in
|
case "$Method $Request_URI" in
|
||||||
"GET /current")
|
|
||||||
printf 'HTTP/1.1 200 OK\r\n'
|
|
||||||
printf 'Connection: close\r\n'
|
|
||||||
printf '\r\n'
|
|
||||||
${print_current_json}/bin/print_current_json
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
"POST /skip")
|
"POST /skip")
|
||||||
printf 'HTTP/1.1 200 OK\r\n'
|
printf 'HTTP/1.1 200 OK\r\n'
|
||||||
printf 'Connection: close\r\n'
|
printf 'Connection: close\r\n'
|
||||||
@ -365,7 +239,7 @@ in {
|
|||||||
alias /var/lib/radio/recent;
|
alias /var/lib/radio/recent;
|
||||||
'';
|
'';
|
||||||
locations."= /current".extraConfig = ''
|
locations."= /current".extraConfig = ''
|
||||||
proxy_pass http://localhost:8001;
|
proxy_pass http://localhost:8002;
|
||||||
'';
|
'';
|
||||||
locations."= /skip".extraConfig = ''
|
locations."= /skip".extraConfig = ''
|
||||||
proxy_pass http://localhost:8001;
|
proxy_pass http://localhost:8001;
|
||||||
@ -375,10 +249,11 @@ in {
|
|||||||
'';
|
'';
|
||||||
locations."= /radio.sh".alias = pkgs.writeScript "radio.sh" ''
|
locations."= /radio.sh".alias = pkgs.writeScript "radio.sh" ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
trap 'exit 0' EXIT
|
||||||
while sleep 1; do
|
while sleep 1; do
|
||||||
mpv \
|
mpv \
|
||||||
--cache-secs=0 --demuxer-readahead-secs=0 --untimed --cache-pause=no \
|
--cache-secs=0 --demuxer-readahead-secs=0 --untimed --cache-pause=no \
|
||||||
'http://lassul.us:8000/radio.opus'
|
'http://lassul.us:8000/radio.ogg'
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
locations."= /controls".extraConfig = ''
|
locations."= /controls".extraConfig = ''
|
||||||
|
@ -3,7 +3,8 @@ let
|
|||||||
|
|
||||||
send_to_radio = pkgs.writers.writeDashBin "send_to_radio" ''
|
send_to_radio = pkgs.writers.writeDashBin "send_to_radio" ''
|
||||||
${pkgs.vorbis-tools}/bin/oggenc - |
|
${pkgs.vorbis-tools}/bin/oggenc - |
|
||||||
${pkgs.libshout}/bin/shout --format ogg --host localhost --port 1338 --mount /live
|
${pkgs.cyberlocker-tools}/bin/cput news.ogg
|
||||||
|
${pkgs.curl}/bin/curl -fSs -X POST http://localhost:8002/newsshow
|
||||||
'';
|
'';
|
||||||
|
|
||||||
gc_news = pkgs.writers.writeDashBin "gc_news" ''
|
gc_news = pkgs.writers.writeDashBin "gc_news" ''
|
||||||
|
111
lass/2configs/radio/radio.liq
Normal file
111
lass/2configs/radio/radio.liq
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
log.stdout.set(true)
|
||||||
|
|
||||||
|
# use yt-dlp
|
||||||
|
settings.protocol.youtube_dl.path.set("yt-dlp")
|
||||||
|
|
||||||
|
## functions
|
||||||
|
|
||||||
|
def stringify_attrs(attrs) =
|
||||||
|
let json.stringify out = (attrs : [(string * string)] as json.object)
|
||||||
|
out
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter_graveyard(req) =
|
||||||
|
filename = request.filename(req)
|
||||||
|
if string.match(pattern = '.*/\\.graveyard/.*', filename) then
|
||||||
|
false
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def queue_contents(q) =
|
||||||
|
list.map(fun (req) -> request.uri(req), q)
|
||||||
|
end
|
||||||
|
## main
|
||||||
|
|
||||||
|
env = environment()
|
||||||
|
port = string.to_int(env["RADIO_PORT"], default = 8000)
|
||||||
|
|
||||||
|
all_music = playlist(env["MUSIC"], check_next = filter_graveyard)
|
||||||
|
wishlist = request.queue()
|
||||||
|
tracks = fallback(track_sensitive = true, [wishlist, all_music])
|
||||||
|
|
||||||
|
last_metadata = ref([])
|
||||||
|
def on_metadata(m) =
|
||||||
|
last_metadata := m
|
||||||
|
print("changing tracks")
|
||||||
|
out = process.read(env["HOOK_TRACK_CHANGE"], env = m)
|
||||||
|
print(out)
|
||||||
|
end
|
||||||
|
tracks.on_metadata(on_metadata)
|
||||||
|
|
||||||
|
# some nice effects
|
||||||
|
music = crossfade(tracks)
|
||||||
|
music = mksafe(music)
|
||||||
|
music = normalize(music)
|
||||||
|
|
||||||
|
news = request.queue()
|
||||||
|
radio = smooth_add(normal = music, special = amplify(1.5, news))
|
||||||
|
|
||||||
|
if string.length(env["ICECAST_HOST"]) > 0 then
|
||||||
|
output.icecast(host = env["ICECAST_HOST"], mount = '/music.ogg', password = 'hackme', %vorbis(quality = 1), music)
|
||||||
|
output.icecast(host = env["ICECAST_HOST"], mount = '/music.mp3', password = 'hackme', %mp3.vbr(), music)
|
||||||
|
output.icecast(host = env["ICECAST_HOST"], mount = '/music.opus', password = 'hackme', %opus(bitrate = 128), music)
|
||||||
|
|
||||||
|
output.icecast(host = env["ICECAST_HOST"], mount = '/radio.ogg', password = 'hackme', %vorbis(quality = 1), radio)
|
||||||
|
output.icecast(host = env["ICECAST_HOST"], mount = '/radio.mp3', password = 'hackme', %mp3.vbr(), radio)
|
||||||
|
output.icecast(host = env["ICECAST_HOST"], mount = '/radio.opus', password = 'hackme', %opus(bitrate = 128), radio)
|
||||||
|
else
|
||||||
|
output(fallible = true, buffer(radio))
|
||||||
|
end
|
||||||
|
|
||||||
|
interactive.harbor(port = port)
|
||||||
|
|
||||||
|
def current(~protocol, ~headers, ~data, uri) =
|
||||||
|
http.response(content_type = "application/json", data = stringify_attrs(
|
||||||
|
!last_metadata
|
||||||
|
))
|
||||||
|
end
|
||||||
|
harbor.http.register("/current", port = port, current)
|
||||||
|
|
||||||
|
def skip(~protocol, ~headers, ~data, uri) =
|
||||||
|
tracks.skip()
|
||||||
|
http.response(content_type = "application/json", data = stringify_attrs(
|
||||||
|
!last_metadata
|
||||||
|
))
|
||||||
|
end
|
||||||
|
harbor.http.register("/skip", method = "POST", port = port, skip)
|
||||||
|
|
||||||
|
def all_tracks(~protocol, ~headers, ~data, uri) =
|
||||||
|
http.response(content_type = "application/json", data = json.stringify(
|
||||||
|
all_music.remaining_files()
|
||||||
|
))
|
||||||
|
end
|
||||||
|
harbor.http.register("/all_tracks", port = port, all_tracks)
|
||||||
|
|
||||||
|
def wish_track(~protocol, ~headers, ~data, uri) =
|
||||||
|
# disallow process:
|
||||||
|
if string.match(pattern = '^process:', data) then
|
||||||
|
http.response(code = 400)
|
||||||
|
else
|
||||||
|
# TODO report errors back
|
||||||
|
wish = request.create(data)
|
||||||
|
wishlist.push(wish)
|
||||||
|
http.response(content_type = "application/json", data = "ok")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
harbor.http.register("/wish", method = "POST", port = port, wish_track)
|
||||||
|
|
||||||
|
def wish_tracklist(~protocol, ~headers, ~data, uri) =
|
||||||
|
http.response(content_type = "application/json", data = json.stringify(
|
||||||
|
queue_contents(wishlist.queue())
|
||||||
|
))
|
||||||
|
end
|
||||||
|
harbor.http.register("/wish", port = port, wish_tracklist)
|
||||||
|
|
||||||
|
def newsshow(~protocol, ~headers, ~data, uri) =
|
||||||
|
news.push(request.create("http://c.r/news.ogg"))
|
||||||
|
http.response(content_type = "application/json", data = "ok")
|
||||||
|
end
|
||||||
|
harbor.http.register("/newsshow", method = "POST", port = port, newsshow)
|
7
lass/2configs/radio/shell.nix
Normal file
7
lass/2configs/radio/shell.nix
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.liquidsoap
|
||||||
|
pkgs.yt-dlp
|
||||||
|
];
|
||||||
|
}
|
@ -6,7 +6,7 @@ let
|
|||||||
} ./weather_for_ips.py;
|
} ./weather_for_ips.py;
|
||||||
|
|
||||||
weather_report = pkgs.writers.writeDashBin "weather_report" ''
|
weather_report = pkgs.writers.writeDashBin "weather_report" ''
|
||||||
set -efu
|
set -efux
|
||||||
export PATH="${lib.makeBinPath [
|
export PATH="${lib.makeBinPath [
|
||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
pkgs.curl
|
pkgs.curl
|
||||||
@ -14,7 +14,7 @@ let
|
|||||||
pkgs.jc
|
pkgs.jc
|
||||||
pkgs.jq
|
pkgs.jq
|
||||||
]}"
|
]}"
|
||||||
curl -z /tmp/GeoLite2-City.mmdb -o /tmp/GeoLite2-City.mmdb http://c.r/GeoLite2-City.mmdb
|
curl -fSsz /tmp/GeoLite2-City.mmdb -o /tmp/GeoLite2-City.mmdb http://c.r/GeoLite2-City.mmdb
|
||||||
MAXMIND_GEOIP_DB="/tmp/GeoLite2-City.mmdb"; export MAXMIND_GEOIP_DB
|
MAXMIND_GEOIP_DB="/tmp/GeoLite2-City.mmdb"; export MAXMIND_GEOIP_DB
|
||||||
OPENWEATHER_API_KEY=$(cat "$CREDENTIALS_DIRECTORY/openweather_api"); export OPENWEATHER_API_KEY
|
OPENWEATHER_API_KEY=$(cat "$CREDENTIALS_DIRECTORY/openweather_api"); export OPENWEATHER_API_KEY
|
||||||
ss -no 'sport = :8000' |
|
ss -no 'sport = :8000' |
|
||||||
@ -42,7 +42,7 @@ in {
|
|||||||
--arg to "$(date -u +'%FT%TZ' -d '+1 hours')" \
|
--arg to "$(date -u +'%FT%TZ' -d '+1 hours')" \
|
||||||
--slurp --raw-input --compact-output --ascii-output \
|
--slurp --raw-input --compact-output --ascii-output \
|
||||||
'{text: ., from: $from, to: $to, priority: 100}' |
|
'{text: ., from: $from, to: $to, priority: 100}' |
|
||||||
retry -t 5 -d 10 -- curl -v -d@- http://radio-news.r
|
retry -t 5 -d 10 -- curl -fSs -d@- http://radio-news.r
|
||||||
'';
|
'';
|
||||||
startAt = "*:58:00";
|
startAt = "*:58:00";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
@ -24,9 +24,10 @@ for ip in fileinput.input():
|
|||||||
weather = json.loads(resp.text)
|
weather = json.loads(resp.text)
|
||||||
output.append(
|
output.append(
|
||||||
f'Weather report for {location.city.name}, {location.country.name}. '
|
f'Weather report for {location.city.name}, {location.country.name}. '
|
||||||
f'Currently it is {weather["current"]["weather"][0]["description"]} outside '
|
f'It is {weather["current"]["weather"][0]["description"]} outside '
|
||||||
f'with a temperature of {weather["current"]["temp"]:.1f} degrees, '
|
f'with a temperature of {weather["current"]["temp"]:.1f} degrees, '
|
||||||
f'and a wind speed of {weather["current"]["wind_speed"]:.1f} meters per second. '
|
f'a wind speed of {weather["current"]["wind_speed"]:.1f} meters per second '
|
||||||
|
f'and a humidity of {weather["current"]["humidity"]} percent. '
|
||||||
f'The probability of precipitation is {weather["hourly"][0]["pop"] * 100:.0f} percent. '
|
f'The probability of precipitation is {weather["hourly"][0]["pop"] * 100:.0f} percent. '
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user