Add archive mode where JSON is saved only

This commit is contained in:
Raynor 2022-12-21 03:21:55 +00:00
parent f561bb4521
commit 2acfdf264f
4 changed files with 24 additions and 20 deletions

2
.gitignore vendored
View File

@ -12,4 +12,4 @@ data/20221219.json
config/hashtag-urls.txt
config/urls.txt
data/20221219.uris.txt
./data/*
data/*

View File

@ -1,7 +1,7 @@
version: "3.9 "
services:
fake-firehose:
firehose-archive:
build: .
image: fakefirehose:latest
volumes:

View File

@ -82,7 +82,7 @@ cat /config/hashtag-urls.txt >> /config/urls.txt
cat /config/urls.txt | while read -r url
do
echo "Opening $url to stream"
sleep 1s
sleep 0.1s
./stream-url.sh $url &
done

View File

@ -12,26 +12,30 @@ do
today=`date +"%Y%m%d"`
echo "Starting to stream $url in 5 seconds"
echo "Archive status is $archive"
sleep 5s;
curl -X "GET" "$url" \
--no-progress-meter | \
tee -a "/data/$today.json" | \
grep url | \
sed 's/data://g' | \
if [[ $archive != "true" ]]
then
curl -X "GET" "$url" \
--no-progress-meter | \
tee -a "/data/$today.json" | \
grep url | \
sed 's/data://g' | \
while read -r line
do
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'`
if [[ $line == *"uri"* ]]
then
url=`echo $line | jq .url| sed 's/\"//g'`
uri=`echo $line | jq .uri| sed 's/\"//g'`
echo "STREAMING from $host $url"
echo $uri >> "/data/$today.uris.txt"
fi
done
echo "STREAMING from $host $url"
echo $uri >> "/data/$today.uris.txt"
fi
done
else
curl -X "GET" "$url" --no-progress-meter >> "/data/$today.$host.json"
fi
done