fixes "empty topic tag bug"

Honestly just stupid change that unbreaks this code (something I should do at the beginning). Stupid fix but works
This commit is contained in:
Pták 2024-06-06 19:02:28 +02:00
parent c9a6c61f69
commit f25d0b0bfa

View file

@ -33,6 +33,14 @@ def save_to_json(event_list):
with open('events.json', 'w') as fp:
json.dump(event_array, fp)
def set_name(raw_event):
try:
if raw_event["post"]["topic"]["tags"][0] == 'closed-event':
event_name = "Closed"
return event_name
except:
event_name = raw_event["post"]["topic"]["title"]
return event_name
def parse_time(timestring):
if timestring!= None:
@ -54,10 +62,7 @@ def create_event_list(json):
if event_end_time == None or event_first_start_datetime==event_end_time:
event_end_time=offset_time(event_first_start_datetime, 1.5)
if raw_event["post"]["topic"]["tags"][0] == 'closed-event':
event_name = "Closed"
else:
event_name = raw_event["post"]["topic"]["title"]
event_name = set_name(raw_event)
event_list.append((event_first_start_datetime,event_name,event_end_time))