diff --git a/src/lib/schedule_week.py b/src/lib/schedule_week.py index 587a651..d0ac8ff 100644 --- a/src/lib/schedule_week.py +++ b/src/lib/schedule_week.py @@ -46,7 +46,7 @@ def get_schedule_week(url: str): schedule_week = [] for i in range(len(rows)): - if rows[i].find("td", class_="KuvSuplovanaHodina") is not None and rows[i].find("td", class_="KuvSuplujiciHodina") is None and rows[i].find("td", class_="KuvSkolniAkceHodina") is None: + if rows[i].find("td", class_="KuvSuplovanaHodina") is not None and rows[i].find("td", class_="KuvSuplujiciHodina") is None and rows[i].find("td", class_="KuvSkolniAkceHodina") is None and rows[i].find("td", class_="DctInnerTableType10DataTD") is None: continue subjects = [] @@ -74,6 +74,8 @@ def get_schedule_week(url: str): for j in range(len(subjects_)): if "KuvSuplovanaHodina" not in subjects_[j].parent["class"]: temp.append(subjects_[j].text) + else: + temp.append("Volno") subjects = temp F_continue = False @@ -106,12 +108,23 @@ def get_schedule_week(url: str): for j in range(len(cells)): if cells[j].get("colspan") is not None: if int(cells[j].get("colspan")) == 2: - subjects.insert(j, subjects[j-1]) - wheres.insert(j, wheres[j-1]) + try: + subjects.insert(j, subjects[j]) + wheres.insert(j, wheres[j]) + except IndexError: + pass for j in range(len(subjects)): if subjects[j] == "Volno": wheres.insert(j, " - ") + while True: + if len(subjects) > len(wheres): + del subjects[-1] + elif len(subjects) < len(wheres): + del wheres[-1] + else: + break + if F_continue == False: schedule_week_row = { "DAY": day, @@ -123,7 +136,7 @@ def get_schedule_week(url: str): schedule_week.append(schedule_week_row) sorted_schedule_week = sort_schedule_week(schedule_week) - + return sorted_schedule_week except AttributeError: global not_login