about summary refs log tree commit diff
path: root/gcc.sh
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2024-03-26 23:01:17 +0000
committerZach DeCook <zachdecook@librem.one>2024-03-26 23:13:36 +0000
commit89342a2b25da87457bc278638d3740767337e45b (patch)
tree253971f59f4041e7f44708479793fd1f3842998e /gcc.sh
parente4be862a7857f9d0ebd5308437de1531e694b685 (diff)
downloadcgi-bin-89342a2b25da87457bc278638d3740767337e45b.tar.gz
GCC script: redirect or provide links
Diffstat (limited to 'gcc.sh')
-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"