live.sh: add

This commit is contained in:
Astro 2022-11-16 02:20:25 +01:00
parent a12dc753b3
commit 8e3f9b9734
1 changed files with 24 additions and 0 deletions

24
live.sh Executable file
View File

@ -0,0 +1,24 @@
#! /usr/bin/env bash
if [ -n "$HOST" ]; then
HOST="$1"
else
HOST=fedi.buzz
fi
curl -s https://$HOST/api/v1/streaming/public | (
IFS="
"
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
while read -r line; do
if [[ "$line" =~ ^data:\ (.+)$ ]]; then
NAME="$(echo "${BASH_REMATCH[1]}" | jq -r .account.display_name 2>/dev/null)"
if [ -n "$NAME" ]; then
TEXT="$(echo "${BASH_REMATCH[1]}" | jq -r .content | sed -e 's/<[^>]*>//g')"
echo "<$BOLD$NAME$NORMAL> $TEXT"
fi
fi
done
)