From 9a862040dc2cbf87a8f3230595c6e96a027ebc25 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 17 Dec 2020 14:49:38 +0100 Subject: l radio: remove icecast, let mpd stream directly (icecast has hiccups) --- lass/2configs/radio.nix | 61 +++++++++---------------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) (limited to 'lass/2configs/radio.nix') diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 3e8d12381..f15e36a69 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -6,9 +6,6 @@ let name = "radio"; mainUser = config.users.extraUsers.mainUser; - admin-password = import ; - source-password = import ; - music_dir = "/home/radio/music"; add_random = pkgs.writeDashBin "add_random" '' @@ -138,54 +135,19 @@ in { auto_update "yes" audio_output { - type "shout" - encoding "lame" - name "the_playlist_mp3" - host "localhost" - port "8000" - mount "/radio.mp3" - password "${source-password}" - bitrate "128" - - format "44100:16:2" - - user "source" - genre "good music" - } - audio_output { - type "shout" - encoding "ogg" - name "the_playlist_ogg" - host "localhost" - port "8000" - mount "/radio.ogg" - password "${source-password}" - bitrate "128" - - format "44100:16:2" - - user "source" - genre "good music" + type "httpd" + name "lassulus radio" + encoder "vorbis" # optional + port "8000" + quality "5.0" # do not define if bitrate is defined + # bitrate "128" # do not define if quality is defined + format "44100:16:1" + always_on "yes" # prevent MPD from disconnecting all listeners when playback is stopped. + tags "yes" # httpd supports sending tags to listening streams. } ''; }; - services.icecast = { - enable = true; - hostname = "radio.lassul.us"; - admin.password = admin-password; - extraConf = '' - - /radio.mp3 - ${source-password} - - - /radio.ogg - ${source-password} - - ''; - }; - krebs.iptables = { tables = { filter.INPUT.rules = [ @@ -206,7 +168,7 @@ in { systemd.services.radio = let autoAdd = pkgs.writeDash "autoAdd" '' - LIMIT=$1 #in secconds + 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}') @@ -238,8 +200,7 @@ in { ${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 'http://localhost:8000/status-json.xsl' \ - | ${pkgs.jq}/bin/jq '[.icestats.source[].listeners] | add') + listeners=$(${pkgs.iproute}/bin/ss -Hno state established '( sport = :8000 )' | wc -l) echo "$(date -Is)" "$track" | tee -a "$HISTORY_FILE" echo "$(tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE" ${write_to_irc} "playing: $track listeners: $listeners" -- cgit v1.2.3