Skip to content

Instantly share code, notes, and snippets.

@flxai
Last active January 1, 2022 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flxai/206829040a1f472f77b64cfa9106e91e to your computer and use it in GitHub Desktop.
Save flxai/206829040a1f472f77b64cfa9106e91e to your computer and use it in GitHub Desktop.
Dump & analyze waboorrt game logs via API
#!/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
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment