1
0
Fork 0
fake-firehose/scripts/get-stream.sh

49 lines
1.0 KiB
Bash
Raw Normal View History

2022-12-17 05:20:35 +00:00
host=$1
2022-12-18 01:45:49 +00:00
type=$2
if [[ "$host" == "" ]]
then
echo "Empty host: $host"
exit 2
fi
2022-12-17 05:20:35 +00:00
while true
do
today=`date +"%Y%m%d"`
2022-12-18 01:45:49 +00:00
case "$type" in
"federated")
fetch="https://$host/api/v1/streaming/public";;
"local")
fetch="https://$host/api/v1/streaming/public?local=true";;
"hashtags")
fetch="https://$host/api/v1/streaming/hashtag?tag=linux"
echo "Sorry, hash tags aren't implemented yet :("
exit 1
;;
esac
echo "Starting to stream $fetch in 5 seconds"
sleep 5s;
curl -X "GET" "$fetch" \
2022-12-17 05:20:35 +00:00
--no-progress-meter | \
2022-12-17 23:55:34 +00:00
tee -a "/data/$today.json" | \
2022-12-17 05:20:35 +00:00
grep url | \
sed 's/data://g' | \
while read -r line
do
if [[ $line == *"uri"* ]]
then
url=`echo $line | jq .url| sed 's/\"//g'`
uri=`echo $line | jq .uri| sed 's/\"//g'`
2022-12-18 01:45:49 +00:00
echo "STREAMING: $host $url"
echo $uri >> "/data/$today.uris.txt"
2022-12-17 05:20:35 +00:00
fi
done
2022-12-18 01:45:49 +00:00
done