Last active
January 1, 2022 19:34
-
-
Save flxai/206829040a1f472f77b64cfa9106e91e to your computer and use it in GitHub Desktop.
Dump & analyze waboorrt game logs via API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Dump waboorrt game logs | |
rid=0 | |
lid= | |
mkdir -p data | |
if [[ ! -f data/ids.lst ]]; then | |
echo -n > data/ids.lst | |
echo -n > data/elo.jsonl | |
echo -n "Downloading ids" | |
while [[ "$rid" != "$lid" ]]; do | |
rid=$lid | |
gj=$(curl -sX 'GET' "https://waboorrt.flipdot.org/api/games?n=25&from_id=$lid" -H 'accept: application/json') | |
echo "$gj" >> data/elo.jsonl | |
while read -r id; do | |
echo "$id" >> data/ids.lst | |
lid="$id" | |
done <<< $(jq -r '.[].id' <<< "$gj") | |
echo -n . | |
done | |
echo | |
fi | |
l=$(cat data/ids.lst | wc -l) | |
echo "Collecting history for ids..." | |
parallel -j100 "[[ -f '{}' ]] || (curl -sX 'GET' 'https://waboorrt.flipdot.org/api/games/{}' -H 'accept: application/json' -o 'data/{}.json'; echo -en '\033[100D{#}/$l')" < data/ids.lst |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment