scripts for my gemini capsule
GCC script: redirect or provide links
Zach DeCook 2024-03-26
parent e4be862 · commit 89342a2
-rwxr-xr-xgcc.sh19
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc.sh b/gcc.sh
index 024745a..d831072 100755
--- a/gcc.sh
+++ b/gcc.sh
@@ -8,12 +8,19 @@ then
fi
hasmp3=$(echo "$QUERY_STRING"|grep 'mp3')
-if [ ! "$hasmp3" = "" ]
-then
- printf "20 audio/mpeg\r\n"
- mp3=$(wget -q -O - https://gccsatx.com/hymns$PATH_INFO/ | grep \.mp3 | sed 's/ /\n/g' | grep \.mp3 | grep href | cut -d'"' -f2)
- wget -O - $mp3
- exit 0
+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"