video-privacy-today/main.py

45 lines
1.2 KiB
Python

from datetime import datetime
import urllib.request
import json
def extract_day(datetime_str):
dt = datetime.strptime(datetime_str.split()[0], '%Y-%m-%d')
return(dt.date())
all_stuff = None
with urllib.request.urlopen('https://www.emfcamp.org/schedule/2024.json') as url:
all_stuff = json.load(url)
# All things happening today
today = datetime.today().date()
all_today = []
for thing in all_stuff:
day = extract_day(thing['start_date'])
if day == today:
all_today.append(thing)
# Only stages
all_stages = []
for thing in all_today:
if 'Stage' in thing['venue']:
all_stages.append(thing)
# Everything on stages today that's not public
not_public = []
for talk in all_stages:
if talk['video_privacy'] != 'public':
not_public.append(talk)
# Ok, print it
print('TITLE', 'START_TIME', 'END_TIME', 'VENUE', 'PRIVACY', sep=' | ')
print('-'*50)
not_public = sorted(not_public, key = lambda x: x['start_date'])
for e in not_public:
print('\n')
start_time = e['start_date'].split()[1]
end_time = e['end_date'].split()[1]
privacy = 'REVIEW' if e['video_privacy'] == 'review' else 'PRIVATE'
print(e['title'], start_time, end_time, e['venue'], privacy, sep=' | ')