Very basic thing done

This commit is contained in:
Qumarth Jash 2024-05-31 13:32:29 +01:00
parent 64d8aecd94
commit e6829aa423
1 changed files with 21 additions and 15 deletions

36
main.py
View File

@ -4,34 +4,40 @@ import urllib.request
import json import json
def extract_day(datetime_str): def extract_day(datetime_str):
dt = datetime.strptime(datetime_str.split()[0], "%Y-%m-%d") dt = datetime.strptime(datetime_str.split()[0], '%Y-%m-%d')
return(dt.date()) return(dt.date())
all_stuff = None all_stuff = None
with urllib.request.urlopen("https://www.emfcamp.org/schedule/2024.json") as url: with urllib.request.urlopen('https://www.emfcamp.org/schedule/2024.json') as url:
all_stuff = json.load(url) all_stuff = json.load(url)
# All things happening today # All things happening today
today = datetime.today().date() today = datetime.today().date()
all_today = [] all_today = []
for thing in all_stuff: for thing in all_stuff:
day = extract_day(thing["start_date"]) day = extract_day(thing['start_date'])
if day == today: if day == today:
all_today.append(thing) all_today.append(thing)
# Only talks # Only stages
all_talks = [] all_stages = []
for thing in all_today: for thing in all_today:
if thing["type"] == "talk": if 'Stage' in thing['venue']:
all_talks.append(thing) all_stages.append(thing)
# talks_not_private = [] # Everything on stages today that's not public
# for talk in talks_today: not_public = []
# if talk["video_privacy"] != 'public': for talk in all_stages:
# talks_not_private.append(talk) if talk['video_privacy'] != 'public':
not_public.append(talk)
print(len(all_talks)) # Ok, print it
print(len(all_stuff)) print('TITLE', 'START_TIME', 'END_TIME', 'VENUE', 'PRIVACY', sep=' | ')
# print(len(talks_today)) print('-'*50)
# print(len(talks_not_private)) not_public = sorted(not_public, key = lambda x: x['start_date'])
for e in not_public:
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=' | ')