Skip to content

Instantly share code, notes, and snippets.

@chrisboyle
Created October 2, 2023 12:28
Show Gist options
  • Save chrisboyle/f234835a8fafc097274ddf60d15ea1f6 to your computer and use it in GitHub Desktop.
Save chrisboyle/f234835a8fafc097274ddf60d15ea1f6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# * Browse to https://app.expopass.com/events/4jrvzmj/schedule
# * Use devtools to grab the JSON responses from *both* requests like
# https://api.expopass.com/rest/sessions/?ids=...
from datetime import datetime
from dateutil import tz
from hashids import Hashids
import csv
import json
import sys
halifax = tz.gettz("America/Halifax")
hashids = Hashids(salt="Expo", min_length=7)
sessions = []
for path in sys.argv[1:]:
with open(path, 'r') as file:
data = json.load(file)
sessions += data['data']['items']
writer = csv.writer(sys.stdout)
writer.writerow(["Day", "Time", "Location", "URL", "Title", "Description"])
for s in sorted(sessions, key=lambda s: s['starts_at']):
starts_at = datetime.fromtimestamp(int(s['starts_at'][:-6]), tz=halifax)
url = f"https://app.expopass.com/events/4jrvzmj/sessions/{hashids.encode(s['id'])}"
writer.writerow([starts_at.strftime('%a'), starts_at.strftime('%H:%M'),
s['location'], url, s['title'], s['description']])
# Google Sheets accepts the output without issues
# Excel 365 online mangles UTF-8 and doesn't linkify the links
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment