diff --git a/sentralify/__init__.py b/sentralify/__init__.py index 583fbd0..03aaeeb 100644 --- a/sentralify/__init__.py +++ b/sentralify/__init__.py @@ -44,10 +44,7 @@ def sentralify(config: dict, timetable: bool = True, notices: bool = True, calen start = time.time() # So that we can know how long it took to scrape the Sentral data - try: - p = sync_playwright().start() # Start a playwright instance - except playwright._impl._errors.Error: - pass + p = sync_playwright().start() # Start a playwright instance # Initialise the generators and scrapers Sentral = generators diff --git a/sentralify/generators.py b/sentralify/generators.py index 312c167..96f3ed3 100644 --- a/sentralify/generators.py +++ b/sentralify/generators.py @@ -92,7 +92,10 @@ def generate_timetable(data: list): if current_day_data['period'][period]['lessons'] != []: # If it's a period without a lesson, then there's nothing in the lesson parameter timetable[timetable_day]['periods'][period]['full_name'] = current_day_data['period'][period]['lessons'][0]['subject_name'] timetable[timetable_day]['periods'][period]['name'] = current_day_data['period'][period]['lessons'][0]['lesson_class_name'] - timetable[timetable_day]['periods'][period]['room'] = current_day_data['period'][period]['lessons'][0]['room_name'] + try: + timetable[timetable_day]['periods'][period]['room'] = current_day_data['period'][period]['lessons'][0]['room_name'] + except KeyError: # If there's not set it to None: + timetable[timetable_day]['periods'][period]['room'] = None timetable[timetable_day]['periods'][period]['border_colour'] = current_day_data['period'][period]['lessons'][0]['class_border_colour'] timetable[timetable_day]['periods'][period]['background_colour'] = current_day_data['period'][period]['lessons'][0]['class_background_colour'] try: # This checks that there is a teacher during the lesson