There are two parts to this:
1. The main shell script that calls curl and jq
2. The jq filter itself, an external file
# ----------------------------------------------------------------------------------------------------------------
#!/bin/bash
events=$(curl --compressed -s 'https://us-or-rly101.zwift.com/api/public/events/upcoming')
read -r -d '' html_header << EOM
Visible to Non-Participants
| Kilometers |
Minutes |
Laps |
Activity |
Start time |
Link |
EOM
html_footer='
'
echo "$html_header"
echo "$events" | jq -r -f events-filter.jq
echo "$html_footer"
# ----------------------------------------------------------------------------------------------------------------
.[] | select(.invisibleToNonParticipants == false) | "
| \(.distanceInMeters / 1000) |
\(.durationInSeconds / 60) |
\(.laps) |
\(.sport) \(.eventType) |
\(.eventStart | strptime("%Y-%m-%dT%H:%M:%S.000+0000") | mktime | strftime("%F %X%z (%Z) %A")) |
\(.name) |
"