Last active
October 25, 2020 20:16
-
-
Save mtfurlan/9c211566b55dc352249bc2e6af160e7e to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
set -euo pipefail | |
cd $(dirname "$0") | |
# to get auth key go to | |
# https://developers.google.com/calendar/v3/reference/events/list?apix_params=%7B%22calendarId%22%3A%22i3detroit.org_188da54r5a9rejlbnsedft642ok0m%40resource.calendar.google.com%22%2C%22maxResults%22%3A5000%7D | |
# open console | |
# select api key auth only | |
# make request | |
# look in request for api key | |
apikey="" | |
calendarID="i3detroit.org_188da54r5a9rejlbnsedft642ok0m%40resource.calendar.google.com" | |
maxPerQuery=50000 | |
curl --silent -G \ | |
"https://content.googleapis.com/calendar/v3/calendars/$calendarID/events?maxResults=$maxPerQuery&key=$apikey" \ | |
-H 'X-Referer: https://explorer.apis.google.com' > tmp.json | |
# if we ever care about pagination, nextPageToken and nextSyncToken could be useful. | |
#nextPageToken=$(jq -r '.nextPageToken' tmp.json) | |
# | |
#echo "next: $nextPageToken" | |
#exit 0 | |
#curl -G --silent \ | |
# "https://content.googleapis.com/calendar/v3/calendars/$calendarID/events?maxResults=$maxPerQuery&key=$apikey" \ | |
# --data-urlencode "pageToken=$nextPageToken" \ | |
# -H "Authorization: $authKey" > tmp.json | |
cat tmp.json | jq '[.items[] | {"id": .id, "email": .creator.email, "start": .start.dateTime, "end": .end.dateTime}]' > parsed.json | |
echo ".id, .email, .start, .end" > calendar-export-$(date '+%Y-%m-%d').csv | |
cat parsed.json | jq -r '.[] | [.id, .email, .start, .end] | @csv' >> calendar-export-$(date '+%Y-%m-%d').csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment