#!/bin/sh
if [ "$PATH_INFO" = "" ]
then
printf "20 text/gemini\r\n"
wget -q -O - https://gccsatx.com/hymns/ | grep -o 'https://gccsatx.com/hymns/[^/"#]\+/' |cut -d/ -f5 | sed 's@^@=>gcc.sh/@g'
exit 0
fi
hasmp3=$(echo "$QUERY_STRING"|grep 'mp3')
if [ ! "$hasmp3" = "" ]; then
mp3=$(wget -q -O - https://gccsatx.com/hymns$PATH_INFO/ | grep \.mp3 | sed 's/ /\n/g' | grep \.mp3 | grep href | cut -d'"' -f2)
if test "$mp3"; then
if test "$(echo "$mp3" | wc -l)" -gt 1; then
printf "20 text/gemini\r\n"
echo "$mp3" | sed 's/^/=> /g'
exit 0
fi
printf "30 %s\r\n" "$mp3"
exit 0
fi
printf "51 no mp3\r\n"
exit 0
fi
printf "20 text/gemini\r\n"
printf "=>/cgi-bin/gcc.sh$PATH_INFO?.mp3 Listen to this!\n"
if test -e "gcc.cache$PATH_INFO"; then
cat "gcc.cache$PATH_INFO"
exit 0
fi
wget -q -O - https://gccsatx.com/hymns$PATH_INFO/ \
| grep -o '\(\| \|\)[^<>]*\(
@@g' \ | sed 's@