diff --git a/server/parser/untis.js b/server/parser/untis.js index 851cf45..11b2fe1 100644 --- a/server/parser/untis.js +++ b/server/parser/untis.js @@ -1,15 +1,15 @@ import * as cheerio from "cheerio"; -const titles = [ - "class", - "date", - "lesson", - "teacher", - "changedTeacher", - "subject", - "room", - "type", - "notes", -]; +const titleTranslations = { + "Klasse(n)": "class", + Datum: "date", + Stunde: "lesson", + "(Lehrer)": "teacher", + Vertreter: "changedTeacher", + Fach: "subject", + Raum: "room", + Art: "type", + Text: "notes", +}; export function parseSubstitutionPlan(html) { const infos = {}; @@ -36,6 +36,14 @@ export function parseSubstitutionPlan(html) { infos.updatedAt = new Date(timestamp).getTime(); const data = []; + + const titles = []; + const titleElements = $("table.mon_list tr.list th"); + titleElements.each((index, titleElement) => { + const title = $(titleElement).text(); + titles[index] = titleTranslations[title]; + }); + const subsitutionTable = $("table.mon_list tr.list"); // Loop through each table row subsitutionTable.each((_rowcnt, row) => {