diff --git a/edu_master/webinar-checker/checker.py b/edu_master/webinar-checker/checker.py index 011a5a5..e32904f 100644 --- a/edu_master/webinar-checker/checker.py +++ b/edu_master/webinar-checker/checker.py @@ -3,6 +3,7 @@ import json import logging import os import re +import tempfile import time from datetime import datetime, timedelta @@ -545,7 +546,7 @@ def _parse_schedule_cell(cell_html: str) -> list: text = text.strip() if not text: continue - lines = [l.strip() for l in text.split('\n') if l.strip()] + lines = [ln.strip() for ln in text.split('\n') if ln.strip()] if not lines: continue subject = lines[0] if lines else '' @@ -599,9 +600,10 @@ def _parse_schedule_html(table_html: str) -> dict: continue first_cell_text = re.sub(r'<[^>]+>', '', cells[0]).strip() - if not re.match(r'^\d+\.', first_cell_text): - if 'Позакласне' in first_cell_text or re.search(r'colspan\s*=\s*"?(\d+)"?', row): - continue + if not re.match(r'^\d+\.', first_cell_text) and ( + 'Позакласне' in first_cell_text or re.search(r'colspan\s*=\s*"?(\d+)"?', row) + ): + continue lesson_num_match = re.match(r'^(\d+)\.', first_cell_text) lesson_num = lesson_num_match.group(1) if lesson_num_match else '' @@ -647,11 +649,11 @@ async def fetch_schedule_data(phpsessid: str) -> dict | None: logger.error('table.schedule-table not found in DOM') return None - with contextlib.suppress(Exception), open('/tmp/schedule_debug.html', 'w', encoding='utf-8') as f: + debug_path = os.path.join(tempfile.gettempdir(), 'schedule_debug.html') + with contextlib.suppress(Exception), open(debug_path, 'w', encoding='utf-8') as f: f.write(table_html) data = _parse_schedule_html(table_html) - total_lessons = sum(len(entry['classes'].get(c, [])) for day in data['weekdays'].values() for entry in day for c in data['classes']) logger.info(f'Schedule parsed: {len(data["weekdays"])} days, classes={data["classes"]}') return data