-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: music
action: blob
revision:
path_from: music-push
revision_from: refs/heads/master:
path_to:
revision_to:

git.thebackupbox.net

music

git://git.thebackupbox.net/music

blob of:

music

/ music-push

refs/heads/master:/music-push
 #!/bin/bash

 ### this is the default because this is the server I push to sometimes.
 uri="${1:-http://azuracast.tilderadio.org:8005/}"

 ### if you don't have these tools installed, you'll want to edit these assignments manually
 which secret-tool >/dev/null && creds="$(secret-tool lookup "${uri}" "${uri}")" || creds="default-username:default-password"

 if [ "$creds" = default-username:default-password ];then
   echo "URI: $uri"
   printf "not going to continue with default creds. fix ur secrets.\n" >&2
   exit 1
 fi

 which secret-lock >/dev/null && secret-lock
 which uricut >/dev/null && domain="$(printf "%s\n" "$uri" | uricut -d)" || domain="radio.tildeverse.org"
 which uricut >/dev/null && port="$(printf "%s\n" "$uri" | uricut -P)"   || port="8005"

 user="$(printf "%s\n" "$creds" | cut -d: -f1)"
 pass="$(printf "%s\n" "$creds" | cut -d: -f2)"

 ### not as portable. :/ but this is what I used first.
 ##( printf "username: %s\npassword: %s\n" "$user" "$pass" ; printf "%s\n" "${uri}" | uricut ) | urijoin > "${PREFIX}/run/music/pushuri"

 mkdir -p "${PREFIX}/run/music"
 printf "http://%s:%s@%s:%s/\n" "$user" "$pass" "$domain" "$port" > "${PREFIX}/run/music/pushuri"

 host="$domain:$port"

 ### while this is going, I need to find a way to add a hook to the music-setnowplaying
 (sleep 10;music-updateplaying )&

 printf "SOURCE / HTTP/1.1\r
 Host: %s\r
 Content-Type: audio/mpeg\r
 Authorization: Basic %s\r
 Ice-Public: 0\r
 Ice-Name: mic check\r
 Ice-Description: epoch is testing stuff\r
 Ice-URL: file:///dev/null\r
 Ice-Genre: wat\r
 \r
 " "$host" "$(printf "%s\n" "$creds" |base64)" | ncat "$domain" "$port"

 music-pushmeta -f 'a LARP of an internet radio DJ'

 music-record \
   | stdbuf -o0 lame - -r --noreplaygain -s 44.1 -b 128 \
   | cat <(printf \
 "SOURCE / HTTP/1.1\r
 Host: %s\r
 Content-Type: audio/mpeg\r
 Authorization: Basic %s\r
 Ice-Public: 0\r
 Ice-Name: mic check\r
 Ice-Description: epoch is testing stuff\r
 Ice-URL: file:///dev/null\r
 Ice-Genre: wat\r
 \r
 " "$host" "$(printf "%s\n" "$creds" | base64)") /dev/stdin | ncat "${domain}" "${port}" >&2

 xmessage "done pushing music."

-- Response ended

-- Page fetched on Sun Jun 2 16:53:58 2024