diff --git a/get_json.py b/get_json.py index 4ead739..0862a3d 100644 --- a/get_json.py +++ b/get_json.py @@ -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))